blob: 596554a8725e7de303485581dacce3f9ea5b9152 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * arch/powerpc/sysdev/ipic.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * IPIC routines implementations.
5 *
6 * Copyright 2005 Freescale Semiconductor, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/errno.h>
16#include <linux/reboot.h>
17#include <linux/slab.h>
18#include <linux/stddef.h>
19#include <linux/sched.h>
20#include <linux/signal.h>
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +020021#include <linux/syscore_ops.h>
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -050022#include <linux/device.h>
23#include <linux/bootmem.h>
24#include <linux/spinlock.h>
Scott Woodd49747b2007-10-09 12:37:13 -050025#include <linux/fsl_devices.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/irq.h>
27#include <asm/io.h>
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -050028#include <asm/prom.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/ipic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#include "ipic.h"
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033static struct ipic * primary_ipic;
Li Yang77d43092007-12-04 19:01:40 +080034static struct irq_chip ipic_level_irq_chip, ipic_edge_irq_chip;
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +000035static DEFINE_RAW_SPINLOCK(ipic_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37static struct ipic_info ipic_info[] = {
Li Yangf03ca952007-10-19 19:38:43 +080038 [1] = {
Li Yangf03ca952007-10-19 19:38:43 +080039 .mask = IPIC_SIMSR_H,
40 .prio = IPIC_SIPRR_C,
41 .force = IPIC_SIFCR_H,
42 .bit = 16,
43 .prio_mask = 0,
44 },
45 [2] = {
Li Yangf03ca952007-10-19 19:38:43 +080046 .mask = IPIC_SIMSR_H,
47 .prio = IPIC_SIPRR_C,
48 .force = IPIC_SIFCR_H,
49 .bit = 17,
50 .prio_mask = 1,
51 },
John Rigbya7267d62008-01-17 17:05:32 -070052 [3] = {
53 .mask = IPIC_SIMSR_H,
54 .prio = IPIC_SIPRR_C,
55 .force = IPIC_SIFCR_H,
56 .bit = 18,
57 .prio_mask = 2,
58 },
Li Yangf03ca952007-10-19 19:38:43 +080059 [4] = {
Li Yangf03ca952007-10-19 19:38:43 +080060 .mask = IPIC_SIMSR_H,
61 .prio = IPIC_SIPRR_C,
62 .force = IPIC_SIFCR_H,
63 .bit = 19,
64 .prio_mask = 3,
65 },
John Rigbya7267d62008-01-17 17:05:32 -070066 [5] = {
67 .mask = IPIC_SIMSR_H,
68 .prio = IPIC_SIPRR_C,
69 .force = IPIC_SIFCR_H,
70 .bit = 20,
71 .prio_mask = 4,
72 },
73 [6] = {
74 .mask = IPIC_SIMSR_H,
75 .prio = IPIC_SIPRR_C,
76 .force = IPIC_SIFCR_H,
77 .bit = 21,
78 .prio_mask = 5,
79 },
80 [7] = {
81 .mask = IPIC_SIMSR_H,
82 .prio = IPIC_SIPRR_C,
83 .force = IPIC_SIFCR_H,
84 .bit = 22,
85 .prio_mask = 6,
86 },
87 [8] = {
88 .mask = IPIC_SIMSR_H,
89 .prio = IPIC_SIPRR_C,
90 .force = IPIC_SIFCR_H,
91 .bit = 23,
92 .prio_mask = 7,
93 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 [9] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 .mask = IPIC_SIMSR_H,
96 .prio = IPIC_SIPRR_D,
97 .force = IPIC_SIFCR_H,
98 .bit = 24,
99 .prio_mask = 0,
100 },
101 [10] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 .mask = IPIC_SIMSR_H,
103 .prio = IPIC_SIPRR_D,
104 .force = IPIC_SIFCR_H,
105 .bit = 25,
106 .prio_mask = 1,
107 },
108 [11] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 .mask = IPIC_SIMSR_H,
110 .prio = IPIC_SIPRR_D,
111 .force = IPIC_SIFCR_H,
112 .bit = 26,
113 .prio_mask = 2,
114 },
Li Yangf03ca952007-10-19 19:38:43 +0800115 [12] = {
Li Yangf03ca952007-10-19 19:38:43 +0800116 .mask = IPIC_SIMSR_H,
117 .prio = IPIC_SIPRR_D,
118 .force = IPIC_SIFCR_H,
119 .bit = 27,
120 .prio_mask = 3,
121 },
122 [13] = {
Li Yangf03ca952007-10-19 19:38:43 +0800123 .mask = IPIC_SIMSR_H,
124 .prio = IPIC_SIPRR_D,
125 .force = IPIC_SIFCR_H,
126 .bit = 28,
127 .prio_mask = 4,
128 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 [14] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .mask = IPIC_SIMSR_H,
131 .prio = IPIC_SIPRR_D,
132 .force = IPIC_SIFCR_H,
133 .bit = 29,
134 .prio_mask = 5,
135 },
136 [15] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 .mask = IPIC_SIMSR_H,
138 .prio = IPIC_SIPRR_D,
139 .force = IPIC_SIFCR_H,
140 .bit = 30,
141 .prio_mask = 6,
142 },
143 [16] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 .mask = IPIC_SIMSR_H,
145 .prio = IPIC_SIPRR_D,
146 .force = IPIC_SIFCR_H,
147 .bit = 31,
148 .prio_mask = 7,
149 },
150 [17] = {
Li Yang77d43092007-12-04 19:01:40 +0800151 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 .mask = IPIC_SEMSR,
153 .prio = IPIC_SMPRR_A,
154 .force = IPIC_SEFCR,
155 .bit = 1,
156 .prio_mask = 5,
157 },
158 [18] = {
Li Yang77d43092007-12-04 19:01:40 +0800159 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 .mask = IPIC_SEMSR,
161 .prio = IPIC_SMPRR_A,
162 .force = IPIC_SEFCR,
163 .bit = 2,
164 .prio_mask = 6,
165 },
166 [19] = {
Li Yang77d43092007-12-04 19:01:40 +0800167 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 .mask = IPIC_SEMSR,
169 .prio = IPIC_SMPRR_A,
170 .force = IPIC_SEFCR,
171 .bit = 3,
172 .prio_mask = 7,
173 },
174 [20] = {
Li Yang77d43092007-12-04 19:01:40 +0800175 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 .mask = IPIC_SEMSR,
177 .prio = IPIC_SMPRR_B,
178 .force = IPIC_SEFCR,
179 .bit = 4,
180 .prio_mask = 4,
181 },
182 [21] = {
Li Yang77d43092007-12-04 19:01:40 +0800183 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 .mask = IPIC_SEMSR,
185 .prio = IPIC_SMPRR_B,
186 .force = IPIC_SEFCR,
187 .bit = 5,
188 .prio_mask = 5,
189 },
190 [22] = {
Li Yang77d43092007-12-04 19:01:40 +0800191 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 .mask = IPIC_SEMSR,
193 .prio = IPIC_SMPRR_B,
194 .force = IPIC_SEFCR,
195 .bit = 6,
196 .prio_mask = 6,
197 },
198 [23] = {
Li Yang77d43092007-12-04 19:01:40 +0800199 .ack = IPIC_SEPNR,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 .mask = IPIC_SEMSR,
201 .prio = IPIC_SMPRR_B,
202 .force = IPIC_SEFCR,
203 .bit = 7,
204 .prio_mask = 7,
205 },
206 [32] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 .mask = IPIC_SIMSR_H,
208 .prio = IPIC_SIPRR_A,
209 .force = IPIC_SIFCR_H,
210 .bit = 0,
211 .prio_mask = 0,
212 },
213 [33] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 .mask = IPIC_SIMSR_H,
215 .prio = IPIC_SIPRR_A,
216 .force = IPIC_SIFCR_H,
217 .bit = 1,
218 .prio_mask = 1,
219 },
220 [34] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 .mask = IPIC_SIMSR_H,
222 .prio = IPIC_SIPRR_A,
223 .force = IPIC_SIFCR_H,
224 .bit = 2,
225 .prio_mask = 2,
226 },
227 [35] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 .mask = IPIC_SIMSR_H,
229 .prio = IPIC_SIPRR_A,
230 .force = IPIC_SIFCR_H,
231 .bit = 3,
232 .prio_mask = 3,
233 },
234 [36] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .mask = IPIC_SIMSR_H,
236 .prio = IPIC_SIPRR_A,
237 .force = IPIC_SIFCR_H,
238 .bit = 4,
239 .prio_mask = 4,
240 },
241 [37] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 .mask = IPIC_SIMSR_H,
243 .prio = IPIC_SIPRR_A,
244 .force = IPIC_SIFCR_H,
245 .bit = 5,
246 .prio_mask = 5,
247 },
248 [38] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .mask = IPIC_SIMSR_H,
250 .prio = IPIC_SIPRR_A,
251 .force = IPIC_SIFCR_H,
252 .bit = 6,
253 .prio_mask = 6,
254 },
255 [39] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .mask = IPIC_SIMSR_H,
257 .prio = IPIC_SIPRR_A,
258 .force = IPIC_SIFCR_H,
259 .bit = 7,
260 .prio_mask = 7,
261 },
John Rigbya7267d62008-01-17 17:05:32 -0700262 [40] = {
263 .mask = IPIC_SIMSR_H,
264 .prio = IPIC_SIPRR_B,
265 .force = IPIC_SIFCR_H,
266 .bit = 8,
267 .prio_mask = 0,
268 },
269 [41] = {
270 .mask = IPIC_SIMSR_H,
271 .prio = IPIC_SIPRR_B,
272 .force = IPIC_SIFCR_H,
273 .bit = 9,
274 .prio_mask = 1,
275 },
Li Yangf03ca952007-10-19 19:38:43 +0800276 [42] = {
Li Yangf03ca952007-10-19 19:38:43 +0800277 .mask = IPIC_SIMSR_H,
278 .prio = IPIC_SIPRR_B,
279 .force = IPIC_SIFCR_H,
280 .bit = 10,
281 .prio_mask = 2,
282 },
John Rigbya7267d62008-01-17 17:05:32 -0700283 [43] = {
284 .mask = IPIC_SIMSR_H,
285 .prio = IPIC_SIPRR_B,
286 .force = IPIC_SIFCR_H,
287 .bit = 11,
288 .prio_mask = 3,
289 },
Li Yangf03ca952007-10-19 19:38:43 +0800290 [44] = {
Li Yangf03ca952007-10-19 19:38:43 +0800291 .mask = IPIC_SIMSR_H,
292 .prio = IPIC_SIPRR_B,
293 .force = IPIC_SIFCR_H,
294 .bit = 12,
295 .prio_mask = 4,
296 },
297 [45] = {
Li Yangf03ca952007-10-19 19:38:43 +0800298 .mask = IPIC_SIMSR_H,
299 .prio = IPIC_SIPRR_B,
300 .force = IPIC_SIFCR_H,
301 .bit = 13,
302 .prio_mask = 5,
303 },
304 [46] = {
Li Yangf03ca952007-10-19 19:38:43 +0800305 .mask = IPIC_SIMSR_H,
306 .prio = IPIC_SIPRR_B,
307 .force = IPIC_SIFCR_H,
308 .bit = 14,
309 .prio_mask = 6,
310 },
311 [47] = {
Li Yangf03ca952007-10-19 19:38:43 +0800312 .mask = IPIC_SIMSR_H,
313 .prio = IPIC_SIPRR_B,
314 .force = IPIC_SIFCR_H,
315 .bit = 15,
316 .prio_mask = 7,
317 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 [48] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 .mask = IPIC_SEMSR,
320 .prio = IPIC_SMPRR_A,
321 .force = IPIC_SEFCR,
322 .bit = 0,
323 .prio_mask = 4,
324 },
325 [64] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 .mask = IPIC_SIMSR_L,
327 .prio = IPIC_SMPRR_A,
328 .force = IPIC_SIFCR_L,
329 .bit = 0,
330 .prio_mask = 0,
331 },
332 [65] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 .mask = IPIC_SIMSR_L,
334 .prio = IPIC_SMPRR_A,
335 .force = IPIC_SIFCR_L,
336 .bit = 1,
337 .prio_mask = 1,
338 },
339 [66] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 .mask = IPIC_SIMSR_L,
341 .prio = IPIC_SMPRR_A,
342 .force = IPIC_SIFCR_L,
343 .bit = 2,
344 .prio_mask = 2,
345 },
346 [67] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 .mask = IPIC_SIMSR_L,
348 .prio = IPIC_SMPRR_A,
349 .force = IPIC_SIFCR_L,
350 .bit = 3,
351 .prio_mask = 3,
352 },
353 [68] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 .mask = IPIC_SIMSR_L,
355 .prio = IPIC_SMPRR_B,
356 .force = IPIC_SIFCR_L,
357 .bit = 4,
358 .prio_mask = 0,
359 },
360 [69] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 .mask = IPIC_SIMSR_L,
362 .prio = IPIC_SMPRR_B,
363 .force = IPIC_SIFCR_L,
364 .bit = 5,
365 .prio_mask = 1,
366 },
367 [70] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 .mask = IPIC_SIMSR_L,
369 .prio = IPIC_SMPRR_B,
370 .force = IPIC_SIFCR_L,
371 .bit = 6,
372 .prio_mask = 2,
373 },
374 [71] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 .mask = IPIC_SIMSR_L,
376 .prio = IPIC_SMPRR_B,
377 .force = IPIC_SIFCR_L,
378 .bit = 7,
379 .prio_mask = 3,
380 },
381 [72] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 .mask = IPIC_SIMSR_L,
383 .prio = 0,
384 .force = IPIC_SIFCR_L,
385 .bit = 8,
386 },
387 [73] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 .mask = IPIC_SIMSR_L,
389 .prio = 0,
390 .force = IPIC_SIFCR_L,
391 .bit = 9,
392 },
393 [74] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 .mask = IPIC_SIMSR_L,
395 .prio = 0,
396 .force = IPIC_SIFCR_L,
397 .bit = 10,
398 },
399 [75] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .mask = IPIC_SIMSR_L,
401 .prio = 0,
402 .force = IPIC_SIFCR_L,
403 .bit = 11,
404 },
405 [76] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 .mask = IPIC_SIMSR_L,
407 .prio = 0,
408 .force = IPIC_SIFCR_L,
409 .bit = 12,
410 },
411 [77] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 .mask = IPIC_SIMSR_L,
413 .prio = 0,
414 .force = IPIC_SIFCR_L,
415 .bit = 13,
416 },
417 [78] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 .mask = IPIC_SIMSR_L,
419 .prio = 0,
420 .force = IPIC_SIFCR_L,
421 .bit = 14,
422 },
423 [79] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 .mask = IPIC_SIMSR_L,
425 .prio = 0,
426 .force = IPIC_SIFCR_L,
427 .bit = 15,
428 },
429 [80] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 .mask = IPIC_SIMSR_L,
431 .prio = 0,
432 .force = IPIC_SIFCR_L,
433 .bit = 16,
434 },
Li Yangf03ca952007-10-19 19:38:43 +0800435 [81] = {
Li Yangf03ca952007-10-19 19:38:43 +0800436 .mask = IPIC_SIMSR_L,
437 .prio = 0,
438 .force = IPIC_SIFCR_L,
439 .bit = 17,
440 },
441 [82] = {
Li Yangf03ca952007-10-19 19:38:43 +0800442 .mask = IPIC_SIMSR_L,
443 .prio = 0,
444 .force = IPIC_SIFCR_L,
445 .bit = 18,
446 },
John Rigbya7267d62008-01-17 17:05:32 -0700447 [83] = {
448 .mask = IPIC_SIMSR_L,
449 .prio = 0,
450 .force = IPIC_SIFCR_L,
451 .bit = 19,
452 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 [84] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 .mask = IPIC_SIMSR_L,
455 .prio = 0,
456 .force = IPIC_SIFCR_L,
457 .bit = 20,
458 },
459 [85] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 .mask = IPIC_SIMSR_L,
461 .prio = 0,
462 .force = IPIC_SIFCR_L,
463 .bit = 21,
464 },
Li Yangf03ca952007-10-19 19:38:43 +0800465 [86] = {
Li Yangf03ca952007-10-19 19:38:43 +0800466 .mask = IPIC_SIMSR_L,
467 .prio = 0,
468 .force = IPIC_SIFCR_L,
469 .bit = 22,
470 },
471 [87] = {
Li Yangf03ca952007-10-19 19:38:43 +0800472 .mask = IPIC_SIMSR_L,
473 .prio = 0,
474 .force = IPIC_SIFCR_L,
475 .bit = 23,
476 },
477 [88] = {
Li Yangf03ca952007-10-19 19:38:43 +0800478 .mask = IPIC_SIMSR_L,
479 .prio = 0,
480 .force = IPIC_SIFCR_L,
481 .bit = 24,
482 },
483 [89] = {
Li Yangf03ca952007-10-19 19:38:43 +0800484 .mask = IPIC_SIMSR_L,
485 .prio = 0,
486 .force = IPIC_SIFCR_L,
487 .bit = 25,
488 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 [90] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 .mask = IPIC_SIMSR_L,
491 .prio = 0,
492 .force = IPIC_SIFCR_L,
493 .bit = 26,
494 },
495 [91] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .mask = IPIC_SIMSR_L,
497 .prio = 0,
498 .force = IPIC_SIFCR_L,
499 .bit = 27,
500 },
Kim Phillips8cf6b1952008-01-24 20:46:50 -0600501 [94] = {
502 .mask = IPIC_SIMSR_L,
503 .prio = 0,
504 .force = IPIC_SIFCR_L,
505 .bit = 30,
506 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507};
508
509static inline u32 ipic_read(volatile u32 __iomem *base, unsigned int reg)
510{
511 return in_be32(base + (reg >> 2));
512}
513
514static inline void ipic_write(volatile u32 __iomem *base, unsigned int reg, u32 value)
515{
516 out_be32(base + (reg >> 2), value);
517}
518
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500519static inline struct ipic * ipic_from_irq(unsigned int virq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520{
521 return primary_ipic;
522}
523
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500524#define ipic_irq_to_hw(virq) ((unsigned int)irq_map[virq].hwirq)
525
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000526static void ipic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000528 struct ipic *ipic = ipic_from_irq(d->irq);
529 unsigned int src = ipic_irq_to_hw(d->irq);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500530 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 u32 temp;
532
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000533 raw_spin_lock_irqsave(&ipic_lock, flags);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500534
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 temp = ipic_read(ipic->regs, ipic_info[src].mask);
536 temp |= (1 << (31 - ipic_info[src].bit));
537 ipic_write(ipic->regs, ipic_info[src].mask, temp);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500538
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000539 raw_spin_unlock_irqrestore(&ipic_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540}
541
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000542static void ipic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543{
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000544 struct ipic *ipic = ipic_from_irq(d->irq);
545 unsigned int src = ipic_irq_to_hw(d->irq);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500546 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 u32 temp;
548
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000549 raw_spin_lock_irqsave(&ipic_lock, flags);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 temp = ipic_read(ipic->regs, ipic_info[src].mask);
552 temp &= ~(1 << (31 - ipic_info[src].bit));
553 ipic_write(ipic->regs, ipic_info[src].mask, temp);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500554
Li Yang77d43092007-12-04 19:01:40 +0800555 /* mb() can't guarantee that masking is finished. But it does finish
556 * for nearly all cases. */
557 mb();
558
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000559 raw_spin_unlock_irqrestore(&ipic_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560}
561
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000562static void ipic_ack_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563{
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000564 struct ipic *ipic = ipic_from_irq(d->irq);
565 unsigned int src = ipic_irq_to_hw(d->irq);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500566 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 u32 temp;
568
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000569 raw_spin_lock_irqsave(&ipic_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570
dayu@datangmobile.cn30c40462009-02-18 13:47:42 +0800571 temp = 1 << (31 - ipic_info[src].bit);
Li Yang77d43092007-12-04 19:01:40 +0800572 ipic_write(ipic->regs, ipic_info[src].ack, temp);
573
574 /* mb() can't guarantee that ack is finished. But it does finish
575 * for nearly all cases. */
576 mb();
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500577
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000578 raw_spin_unlock_irqrestore(&ipic_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579}
580
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000581static void ipic_mask_irq_and_ack(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582{
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000583 struct ipic *ipic = ipic_from_irq(d->irq);
584 unsigned int src = ipic_irq_to_hw(d->irq);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500585 unsigned long flags;
586 u32 temp;
587
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000588 raw_spin_lock_irqsave(&ipic_lock, flags);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500589
590 temp = ipic_read(ipic->regs, ipic_info[src].mask);
591 temp &= ~(1 << (31 - ipic_info[src].bit));
592 ipic_write(ipic->regs, ipic_info[src].mask, temp);
593
dayu@datangmobile.cn30c40462009-02-18 13:47:42 +0800594 temp = 1 << (31 - ipic_info[src].bit);
Li Yang77d43092007-12-04 19:01:40 +0800595 ipic_write(ipic->regs, ipic_info[src].ack, temp);
596
597 /* mb() can't guarantee that ack is finished. But it does finish
598 * for nearly all cases. */
599 mb();
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500600
Thomas Gleixnera9e8bf22010-02-18 02:23:14 +0000601 raw_spin_unlock_irqrestore(&ipic_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602}
603
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000604static int ipic_set_irq_type(struct irq_data *d, unsigned int flow_type)
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500605{
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000606 struct ipic *ipic = ipic_from_irq(d->irq);
607 unsigned int src = ipic_irq_to_hw(d->irq);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500608 unsigned int vold, vnew, edibit;
609
610 if (flow_type == IRQ_TYPE_NONE)
611 flow_type = IRQ_TYPE_LEVEL_LOW;
612
613 /* ipic supports only low assertion and high-to-low change senses
614 */
615 if (!(flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING))) {
616 printk(KERN_ERR "ipic: sense type 0x%x not supported\n",
617 flow_type);
618 return -EINVAL;
619 }
Li Yang77d43092007-12-04 19:01:40 +0800620 /* ipic supports only edge mode on external interrupts */
621 if ((flow_type & IRQ_TYPE_EDGE_FALLING) && !ipic_info[src].ack) {
622 printk(KERN_ERR "ipic: edge sense not supported on internal "
623 "interrupts\n");
624 return -EINVAL;
Thomas Gleixnerecf4b192011-03-25 16:16:30 +0100625
Li Yang77d43092007-12-04 19:01:40 +0800626 }
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500627
Thomas Gleixnerecf4b192011-03-25 16:16:30 +0100628 irqd_set_trigger_type(d, flow_type);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500629 if (flow_type & IRQ_TYPE_LEVEL_LOW) {
Thomas Gleixnerecf4b192011-03-25 16:16:30 +0100630 __irq_set_handler_locked(d->irq, handle_level_irq);
631 d->chip = &ipic_level_irq_chip;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500632 } else {
Thomas Gleixnerecf4b192011-03-25 16:16:30 +0100633 __irq_set_handler_locked(d->irq, handle_edge_irq);
634 d->chip = &ipic_edge_irq_chip;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500635 }
636
637 /* only EXT IRQ senses are programmable on ipic
638 * internal IRQ senses are LEVEL_LOW
639 */
640 if (src == IPIC_IRQ_EXT0)
641 edibit = 15;
642 else
643 if (src >= IPIC_IRQ_EXT1 && src <= IPIC_IRQ_EXT7)
644 edibit = (14 - (src - IPIC_IRQ_EXT1));
645 else
646 return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL;
647
648 vold = ipic_read(ipic->regs, IPIC_SECNR);
649 if ((flow_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_FALLING) {
650 vnew = vold | (1 << edibit);
651 } else {
652 vnew = vold & ~(1 << edibit);
653 }
654 if (vold != vnew)
655 ipic_write(ipic->regs, IPIC_SECNR, vnew);
Thomas Gleixnerecf4b192011-03-25 16:16:30 +0100656 return IRQ_SET_MASK_OK_NOCOPY;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500657}
658
Li Yang77d43092007-12-04 19:01:40 +0800659/* level interrupts and edge interrupts have different ack operations */
660static struct irq_chip ipic_level_irq_chip = {
Anton Blanchardfc380c02010-01-31 20:33:41 +0000661 .name = "IPIC",
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000662 .irq_unmask = ipic_unmask_irq,
663 .irq_mask = ipic_mask_irq,
664 .irq_mask_ack = ipic_mask_irq,
665 .irq_set_type = ipic_set_irq_type,
Li Yang77d43092007-12-04 19:01:40 +0800666};
667
668static struct irq_chip ipic_edge_irq_chip = {
Anton Blanchardfc380c02010-01-31 20:33:41 +0000669 .name = "IPIC",
Lennert Buytenhek687228a2011-03-07 13:59:58 +0000670 .irq_unmask = ipic_unmask_irq,
671 .irq_mask = ipic_mask_irq,
672 .irq_mask_ack = ipic_mask_irq_and_ack,
673 .irq_ack = ipic_ack_irq,
674 .irq_set_type = ipic_set_irq_type,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675};
676
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500677static int ipic_host_match(struct irq_host *h, struct device_node *node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678{
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500679 /* Exact match, unless ipic node is NULL */
Michael Ellerman52964f82007-08-28 18:47:54 +1000680 return h->of_node == NULL || h->of_node == node;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500681}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500683static int ipic_host_map(struct irq_host *h, unsigned int virq,
684 irq_hw_number_t hw)
685{
686 struct ipic *ipic = h->host_data;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500687
Thomas Gleixnerec775d02011-03-25 16:45:20 +0100688 irq_set_chip_data(virq, ipic);
689 irq_set_chip_and_handler(virq, &ipic_level_irq_chip, handle_level_irq);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500690
691 /* Set default irq type */
Thomas Gleixnerec775d02011-03-25 16:45:20 +0100692 irq_set_irq_type(virq, IRQ_TYPE_NONE);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500693
694 return 0;
695}
696
697static int ipic_host_xlate(struct irq_host *h, struct device_node *ct,
Roman Fietze40d50cf2009-12-08 02:39:50 +0000698 const u32 *intspec, unsigned int intsize,
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500699 irq_hw_number_t *out_hwirq, unsigned int *out_flags)
700
701{
702 /* interrupt sense values coming from the device tree equal either
703 * LEVEL_LOW (low assertion) or EDGE_FALLING (high-to-low change)
704 */
705 *out_hwirq = intspec[0];
706 if (intsize > 1)
707 *out_flags = intspec[1];
708 else
709 *out_flags = IRQ_TYPE_NONE;
710 return 0;
711}
712
713static struct irq_host_ops ipic_host_ops = {
714 .match = ipic_host_match,
715 .map = ipic_host_map,
716 .xlate = ipic_host_xlate,
717};
718
Kumar Gala126186a2007-01-26 01:45:32 -0600719struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500720{
721 struct ipic *ipic;
722 struct resource res;
723 u32 temp = 0, ret;
724
Michael Ellerman84f1c1e2008-05-26 12:12:30 +1000725 ret = of_address_to_resource(node, 0, &res);
726 if (ret)
727 return NULL;
728
Anton Vorontsovea960252009-07-01 10:59:57 +0000729 ipic = kzalloc(sizeof(*ipic), GFP_KERNEL);
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500730 if (ipic == NULL)
Kumar Gala126186a2007-01-26 01:45:32 -0600731 return NULL;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500732
Michael Ellerman19fc65b2008-05-26 12:12:32 +1000733 ipic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500734 NR_IPIC_INTS,
735 &ipic_host_ops, 0);
Julia Lawall7a626b62009-08-02 10:44:53 +0200736 if (ipic->irqhost == NULL) {
737 kfree(ipic);
Kumar Gala126186a2007-01-26 01:45:32 -0600738 return NULL;
Julia Lawall7a626b62009-08-02 10:44:53 +0200739 }
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500740
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500741 ipic->regs = ioremap(res.start, res.end - res.start + 1);
742
743 ipic->irqhost->host_data = ipic;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500744
745 /* init hw */
746 ipic_write(ipic->regs, IPIC_SICNR, 0x0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
748 /* default priority scheme is grouped. If spread mode is required
749 * configure SICFR accordingly */
750 if (flags & IPIC_SPREADMODE_GRP_A)
751 temp |= SICFR_IPSA;
Li Yangf03ca952007-10-19 19:38:43 +0800752 if (flags & IPIC_SPREADMODE_GRP_B)
753 temp |= SICFR_IPSB;
754 if (flags & IPIC_SPREADMODE_GRP_C)
755 temp |= SICFR_IPSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 if (flags & IPIC_SPREADMODE_GRP_D)
757 temp |= SICFR_IPSD;
758 if (flags & IPIC_SPREADMODE_MIX_A)
759 temp |= SICFR_MPSA;
760 if (flags & IPIC_SPREADMODE_MIX_B)
761 temp |= SICFR_MPSB;
762
Li Yangf03ca952007-10-19 19:38:43 +0800763 ipic_write(ipic->regs, IPIC_SICFR, temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764
765 /* handle MCP route */
766 temp = 0;
767 if (flags & IPIC_DISABLE_MCP_OUT)
768 temp = SERCR_MCPR;
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500769 ipic_write(ipic->regs, IPIC_SERCR, temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770
771 /* handle routing of IRQ0 to MCP */
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500772 temp = ipic_read(ipic->regs, IPIC_SEMSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773
774 if (flags & IPIC_IRQ0_MCP)
775 temp |= SEMSR_SIRQ0;
776 else
777 temp &= ~SEMSR_SIRQ0;
778
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500779 ipic_write(ipic->regs, IPIC_SEMSR, temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500781 primary_ipic = ipic;
782 irq_set_default_host(primary_ipic->irqhost);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783
Sebastian Andrzej Siewior8640d3b2009-08-05 21:41:12 +0200784 ipic_write(ipic->regs, IPIC_SIMSR_H, 0);
785 ipic_write(ipic->regs, IPIC_SIMSR_L, 0);
786
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500787 printk ("IPIC (%d IRQ sources) at %p\n", NR_IPIC_INTS,
788 primary_ipic->regs);
Kumar Gala126186a2007-01-26 01:45:32 -0600789
790 return ipic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791}
792
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500793int ipic_set_priority(unsigned int virq, unsigned int priority)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794{
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500795 struct ipic *ipic = ipic_from_irq(virq);
796 unsigned int src = ipic_irq_to_hw(virq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 u32 temp;
798
799 if (priority > 7)
800 return -EINVAL;
801 if (src > 127)
802 return -EINVAL;
803 if (ipic_info[src].prio == 0)
804 return -EINVAL;
805
806 temp = ipic_read(ipic->regs, ipic_info[src].prio);
807
808 if (priority < 4) {
809 temp &= ~(0x7 << (20 + (3 - priority) * 3));
810 temp |= ipic_info[src].prio_mask << (20 + (3 - priority) * 3);
811 } else {
812 temp &= ~(0x7 << (4 + (7 - priority) * 3));
813 temp |= ipic_info[src].prio_mask << (4 + (7 - priority) * 3);
814 }
815
816 ipic_write(ipic->regs, ipic_info[src].prio, temp);
817
818 return 0;
819}
820
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500821void ipic_set_highest_priority(unsigned int virq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822{
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500823 struct ipic *ipic = ipic_from_irq(virq);
824 unsigned int src = ipic_irq_to_hw(virq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 u32 temp;
826
827 temp = ipic_read(ipic->regs, IPIC_SICFR);
828
829 /* clear and set HPI */
830 temp &= 0x7f000000;
831 temp |= (src & 0x7f) << 24;
832
833 ipic_write(ipic->regs, IPIC_SICFR, temp);
834}
835
836void ipic_set_default_priority(void)
837{
Li Yangf03ca952007-10-19 19:38:43 +0800838 ipic_write(primary_ipic->regs, IPIC_SIPRR_A, IPIC_PRIORITY_DEFAULT);
839 ipic_write(primary_ipic->regs, IPIC_SIPRR_B, IPIC_PRIORITY_DEFAULT);
840 ipic_write(primary_ipic->regs, IPIC_SIPRR_C, IPIC_PRIORITY_DEFAULT);
841 ipic_write(primary_ipic->regs, IPIC_SIPRR_D, IPIC_PRIORITY_DEFAULT);
842 ipic_write(primary_ipic->regs, IPIC_SMPRR_A, IPIC_PRIORITY_DEFAULT);
843 ipic_write(primary_ipic->regs, IPIC_SMPRR_B, IPIC_PRIORITY_DEFAULT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844}
845
846void ipic_enable_mcp(enum ipic_mcp_irq mcp_irq)
847{
848 struct ipic *ipic = primary_ipic;
849 u32 temp;
850
851 temp = ipic_read(ipic->regs, IPIC_SERMR);
852 temp |= (1 << (31 - mcp_irq));
853 ipic_write(ipic->regs, IPIC_SERMR, temp);
854}
855
856void ipic_disable_mcp(enum ipic_mcp_irq mcp_irq)
857{
858 struct ipic *ipic = primary_ipic;
859 u32 temp;
860
861 temp = ipic_read(ipic->regs, IPIC_SERMR);
862 temp &= (1 << (31 - mcp_irq));
863 ipic_write(ipic->regs, IPIC_SERMR, temp);
864}
865
866u32 ipic_get_mcp_status(void)
867{
868 return ipic_read(primary_ipic->regs, IPIC_SERMR);
869}
870
871void ipic_clear_mcp_status(u32 mask)
872{
873 ipic_write(primary_ipic->regs, IPIC_SERMR, mask);
874}
875
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500876/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
Olaf Hering35a84c22006-10-07 22:08:26 +1000877unsigned int ipic_get_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878{
879 int irq;
880
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500881 BUG_ON(primary_ipic == NULL);
882
883#define IPIC_SIVCR_VECTOR_MASK 0x7f
884 irq = ipic_read(primary_ipic->regs, IPIC_SIVCR) & IPIC_SIVCR_VECTOR_MASK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885
886 if (irq == 0) /* 0 --> no irq is pending */
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500887 return NO_IRQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888
Kim Phillipsb9f0f1b2006-08-25 11:59:07 -0500889 return irq_linear_revmap(primary_ipic->irqhost, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890}
891
Michael Neulinge2a02ba2009-02-06 11:10:27 +1100892#ifdef CONFIG_SUSPEND
Scott Woodd49747b2007-10-09 12:37:13 -0500893static struct {
894 u32 sicfr;
895 u32 siprr[2];
896 u32 simsr[2];
897 u32 sicnr;
898 u32 smprr[2];
899 u32 semsr;
900 u32 secnr;
901 u32 sermr;
902 u32 sercr;
903} ipic_saved_state;
904
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +0200905static int ipic_suspend(void)
Scott Woodd49747b2007-10-09 12:37:13 -0500906{
907 struct ipic *ipic = primary_ipic;
908
909 ipic_saved_state.sicfr = ipic_read(ipic->regs, IPIC_SICFR);
910 ipic_saved_state.siprr[0] = ipic_read(ipic->regs, IPIC_SIPRR_A);
911 ipic_saved_state.siprr[1] = ipic_read(ipic->regs, IPIC_SIPRR_D);
912 ipic_saved_state.simsr[0] = ipic_read(ipic->regs, IPIC_SIMSR_H);
913 ipic_saved_state.simsr[1] = ipic_read(ipic->regs, IPIC_SIMSR_L);
914 ipic_saved_state.sicnr = ipic_read(ipic->regs, IPIC_SICNR);
915 ipic_saved_state.smprr[0] = ipic_read(ipic->regs, IPIC_SMPRR_A);
916 ipic_saved_state.smprr[1] = ipic_read(ipic->regs, IPIC_SMPRR_B);
917 ipic_saved_state.semsr = ipic_read(ipic->regs, IPIC_SEMSR);
918 ipic_saved_state.secnr = ipic_read(ipic->regs, IPIC_SECNR);
919 ipic_saved_state.sermr = ipic_read(ipic->regs, IPIC_SERMR);
920 ipic_saved_state.sercr = ipic_read(ipic->regs, IPIC_SERCR);
921
922 if (fsl_deep_sleep()) {
923 /* In deep sleep, make sure there can be no
924 * pending interrupts, as this can cause
925 * problems on 831x.
926 */
927 ipic_write(ipic->regs, IPIC_SIMSR_H, 0);
928 ipic_write(ipic->regs, IPIC_SIMSR_L, 0);
929 ipic_write(ipic->regs, IPIC_SEMSR, 0);
930 ipic_write(ipic->regs, IPIC_SERMR, 0);
931 }
932
933 return 0;
934}
935
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +0200936static void ipic_resume(void)
Scott Woodd49747b2007-10-09 12:37:13 -0500937{
938 struct ipic *ipic = primary_ipic;
939
940 ipic_write(ipic->regs, IPIC_SICFR, ipic_saved_state.sicfr);
941 ipic_write(ipic->regs, IPIC_SIPRR_A, ipic_saved_state.siprr[0]);
942 ipic_write(ipic->regs, IPIC_SIPRR_D, ipic_saved_state.siprr[1]);
943 ipic_write(ipic->regs, IPIC_SIMSR_H, ipic_saved_state.simsr[0]);
944 ipic_write(ipic->regs, IPIC_SIMSR_L, ipic_saved_state.simsr[1]);
945 ipic_write(ipic->regs, IPIC_SICNR, ipic_saved_state.sicnr);
946 ipic_write(ipic->regs, IPIC_SMPRR_A, ipic_saved_state.smprr[0]);
947 ipic_write(ipic->regs, IPIC_SMPRR_B, ipic_saved_state.smprr[1]);
948 ipic_write(ipic->regs, IPIC_SEMSR, ipic_saved_state.semsr);
949 ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr);
950 ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr);
951 ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr);
Scott Woodd49747b2007-10-09 12:37:13 -0500952}
953#else
954#define ipic_suspend NULL
955#define ipic_resume NULL
956#endif
957
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +0200958static struct syscore_ops ipic_syscore_ops = {
Scott Woodd49747b2007-10-09 12:37:13 -0500959 .suspend = ipic_suspend,
960 .resume = ipic_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961};
962
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +0200963static int __init init_ipic_syscore(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964{
Olaf Hering1428a9f2008-03-18 06:53:05 +1100965 if (!primary_ipic || !primary_ipic->regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +0200968 printk(KERN_DEBUG "Registering ipic system core operations\n");
969 register_syscore_ops(&ipic_syscore_ops);
970
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 return 0;
972}
973
Rafael J. Wysockif5a592f2011-04-26 19:14:57 +0200974subsys_initcall(init_ipic_syscore);