mpic.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. /*
  2. * arch/powerpc/kernel/mpic.c
  3. *
  4. * Driver for interrupt controllers following the OpenPIC standard, the
  5. * common implementation beeing IBM's MPIC. This driver also can deal
  6. * with various broken implementations of this HW.
  7. *
  8. * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file COPYING in the main directory of this archive
  12. * for more details.
  13. */
  14. #undef DEBUG
  15. #undef DEBUG_IPI
  16. #undef DEBUG_IRQ
  17. #undef DEBUG_LOW
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/irq.h>
  22. #include <linux/smp.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/bootmem.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/pci.h>
  27. #include <asm/ptrace.h>
  28. #include <asm/signal.h>
  29. #include <asm/io.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/irq.h>
  32. #include <asm/machdep.h>
  33. #include <asm/mpic.h>
  34. #include <asm/smp.h>
  35. #ifdef DEBUG
  36. #define DBG(fmt...) printk(fmt)
  37. #else
  38. #define DBG(fmt...)
  39. #endif
  40. static struct mpic *mpics;
  41. static struct mpic *mpic_primary;
  42. static DEFINE_SPINLOCK(mpic_lock);
  43. #ifdef CONFIG_PPC32 /* XXX for now */
  44. #ifdef CONFIG_IRQ_ALL_CPUS
  45. #define distribute_irqs (1)
  46. #else
  47. #define distribute_irqs (0)
  48. #endif
  49. #endif
  50. /*
  51. * Register accessor functions
  52. */
  53. static inline u32 _mpic_read(unsigned int be, volatile u32 __iomem *base,
  54. unsigned int reg)
  55. {
  56. if (be)
  57. return in_be32(base + (reg >> 2));
  58. else
  59. return in_le32(base + (reg >> 2));
  60. }
  61. static inline void _mpic_write(unsigned int be, volatile u32 __iomem *base,
  62. unsigned int reg, u32 value)
  63. {
  64. if (be)
  65. out_be32(base + (reg >> 2), value);
  66. else
  67. out_le32(base + (reg >> 2), value);
  68. }
  69. static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi)
  70. {
  71. unsigned int be = (mpic->flags & MPIC_BIG_ENDIAN) != 0;
  72. unsigned int offset = MPIC_GREG_IPI_VECTOR_PRI_0 + (ipi * 0x10);
  73. if (mpic->flags & MPIC_BROKEN_IPI)
  74. be = !be;
  75. return _mpic_read(be, mpic->gregs, offset);
  76. }
  77. static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value)
  78. {
  79. unsigned int offset = MPIC_GREG_IPI_VECTOR_PRI_0 + (ipi * 0x10);
  80. _mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->gregs, offset, value);
  81. }
  82. static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
  83. {
  84. unsigned int cpu = 0;
  85. if (mpic->flags & MPIC_PRIMARY)
  86. cpu = hard_smp_processor_id();
  87. return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN,
  88. mpic->cpuregs[cpu], reg);
  89. }
  90. static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
  91. {
  92. unsigned int cpu = 0;
  93. if (mpic->flags & MPIC_PRIMARY)
  94. cpu = hard_smp_processor_id();
  95. _mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->cpuregs[cpu], reg, value);
  96. }
  97. static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg)
  98. {
  99. unsigned int isu = src_no >> mpic->isu_shift;
  100. unsigned int idx = src_no & mpic->isu_mask;
  101. return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu],
  102. reg + (idx * MPIC_IRQ_STRIDE));
  103. }
  104. static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
  105. unsigned int reg, u32 value)
  106. {
  107. unsigned int isu = src_no >> mpic->isu_shift;
  108. unsigned int idx = src_no & mpic->isu_mask;
  109. _mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu],
  110. reg + (idx * MPIC_IRQ_STRIDE), value);
  111. }
  112. #define mpic_read(b,r) _mpic_read(mpic->flags & MPIC_BIG_ENDIAN,(b),(r))
  113. #define mpic_write(b,r,v) _mpic_write(mpic->flags & MPIC_BIG_ENDIAN,(b),(r),(v))
  114. #define mpic_ipi_read(i) _mpic_ipi_read(mpic,(i))
  115. #define mpic_ipi_write(i,v) _mpic_ipi_write(mpic,(i),(v))
  116. #define mpic_cpu_read(i) _mpic_cpu_read(mpic,(i))
  117. #define mpic_cpu_write(i,v) _mpic_cpu_write(mpic,(i),(v))
  118. #define mpic_irq_read(s,r) _mpic_irq_read(mpic,(s),(r))
  119. #define mpic_irq_write(s,r,v) _mpic_irq_write(mpic,(s),(r),(v))
  120. /*
  121. * Low level utility functions
  122. */
  123. /* Check if we have one of those nice broken MPICs with a flipped endian on
  124. * reads from IPI registers
  125. */
  126. static void __init mpic_test_broken_ipi(struct mpic *mpic)
  127. {
  128. u32 r;
  129. mpic_write(mpic->gregs, MPIC_GREG_IPI_VECTOR_PRI_0, MPIC_VECPRI_MASK);
  130. r = mpic_read(mpic->gregs, MPIC_GREG_IPI_VECTOR_PRI_0);
  131. if (r == le32_to_cpu(MPIC_VECPRI_MASK)) {
  132. printk(KERN_INFO "mpic: Detected reversed IPI registers\n");
  133. mpic->flags |= MPIC_BROKEN_IPI;
  134. }
  135. }
  136. #ifdef CONFIG_MPIC_BROKEN_U3
  137. /* Test if an interrupt is sourced from HyperTransport (used on broken U3s)
  138. * to force the edge setting on the MPIC and do the ack workaround.
  139. */
  140. static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source)
  141. {
  142. if (source >= 128 || !mpic->fixups)
  143. return 0;
  144. return mpic->fixups[source].base != NULL;
  145. }
  146. static inline void mpic_ht_end_irq(struct mpic *mpic, unsigned int source)
  147. {
  148. struct mpic_irq_fixup *fixup = &mpic->fixups[source];
  149. if (fixup->applebase) {
  150. unsigned int soff = (fixup->index >> 3) & ~3;
  151. unsigned int mask = 1U << (fixup->index & 0x1f);
  152. writel(mask, fixup->applebase + soff);
  153. } else {
  154. spin_lock(&mpic->fixup_lock);
  155. writeb(0x11 + 2 * fixup->index, fixup->base + 2);
  156. writel(fixup->data, fixup->base + 4);
  157. spin_unlock(&mpic->fixup_lock);
  158. }
  159. }
  160. static void mpic_startup_ht_interrupt(struct mpic *mpic, unsigned int source,
  161. unsigned int irqflags)
  162. {
  163. struct mpic_irq_fixup *fixup = &mpic->fixups[source];
  164. unsigned long flags;
  165. u32 tmp;
  166. if (fixup->base == NULL)
  167. return;
  168. DBG("startup_ht_interrupt(%u, %u) index: %d\n",
  169. source, irqflags, fixup->index);
  170. spin_lock_irqsave(&mpic->fixup_lock, flags);
  171. /* Enable and configure */
  172. writeb(0x10 + 2 * fixup->index, fixup->base + 2);
  173. tmp = readl(fixup->base + 4);
  174. tmp &= ~(0x23U);
  175. if (irqflags & IRQ_LEVEL)
  176. tmp |= 0x22;
  177. writel(tmp, fixup->base + 4);
  178. spin_unlock_irqrestore(&mpic->fixup_lock, flags);
  179. }
  180. static void mpic_shutdown_ht_interrupt(struct mpic *mpic, unsigned int source,
  181. unsigned int irqflags)
  182. {
  183. struct mpic_irq_fixup *fixup = &mpic->fixups[source];
  184. unsigned long flags;
  185. u32 tmp;
  186. if (fixup->base == NULL)
  187. return;
  188. DBG("shutdown_ht_interrupt(%u, %u)\n", source, irqflags);
  189. /* Disable */
  190. spin_lock_irqsave(&mpic->fixup_lock, flags);
  191. writeb(0x10 + 2 * fixup->index, fixup->base + 2);
  192. tmp = readl(fixup->base + 4);
  193. tmp |= 1;
  194. writel(tmp, fixup->base + 4);
  195. spin_unlock_irqrestore(&mpic->fixup_lock, flags);
  196. }
  197. static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase,
  198. unsigned int devfn, u32 vdid)
  199. {
  200. int i, irq, n;
  201. u8 __iomem *base;
  202. u32 tmp;
  203. u8 pos;
  204. for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0;
  205. pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) {
  206. u8 id = readb(devbase + pos + PCI_CAP_LIST_ID);
  207. if (id == PCI_CAP_ID_HT_IRQCONF) {
  208. id = readb(devbase + pos + 3);
  209. if (id == 0x80)
  210. break;
  211. }
  212. }
  213. if (pos == 0)
  214. return;
  215. base = devbase + pos;
  216. writeb(0x01, base + 2);
  217. n = (readl(base + 4) >> 16) & 0xff;
  218. printk(KERN_INFO "mpic: - HT:%02x.%x [0x%02x] vendor %04x device %04x"
  219. " has %d irqs\n",
  220. devfn >> 3, devfn & 0x7, pos, vdid & 0xffff, vdid >> 16, n + 1);
  221. for (i = 0; i <= n; i++) {
  222. writeb(0x10 + 2 * i, base + 2);
  223. tmp = readl(base + 4);
  224. irq = (tmp >> 16) & 0xff;
  225. DBG("HT PIC index 0x%x, irq 0x%x, tmp: %08x\n", i, irq, tmp);
  226. /* mask it , will be unmasked later */
  227. tmp |= 0x1;
  228. writel(tmp, base + 4);
  229. mpic->fixups[irq].index = i;
  230. mpic->fixups[irq].base = base;
  231. /* Apple HT PIC has a non-standard way of doing EOIs */
  232. if ((vdid & 0xffff) == 0x106b)
  233. mpic->fixups[irq].applebase = devbase + 0x60;
  234. else
  235. mpic->fixups[irq].applebase = NULL;
  236. writeb(0x11 + 2 * i, base + 2);
  237. mpic->fixups[irq].data = readl(base + 4) | 0x80000000;
  238. }
  239. }
  240. static void __init mpic_scan_ht_pics(struct mpic *mpic)
  241. {
  242. unsigned int devfn;
  243. u8 __iomem *cfgspace;
  244. printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
  245. /* Allocate fixups array */
  246. mpic->fixups = alloc_bootmem(128 * sizeof(struct mpic_irq_fixup));
  247. BUG_ON(mpic->fixups == NULL);
  248. memset(mpic->fixups, 0, 128 * sizeof(struct mpic_irq_fixup));
  249. /* Init spinlock */
  250. spin_lock_init(&mpic->fixup_lock);
  251. /* Map U3 config space. We assume all IO-APICs are on the primary bus
  252. * so we only need to map 64kB.
  253. */
  254. cfgspace = ioremap(0xf2000000, 0x10000);
  255. BUG_ON(cfgspace == NULL);
  256. /* Now we scan all slots. We do a very quick scan, we read the header
  257. * type, vendor ID and device ID only, that's plenty enough
  258. */
  259. for (devfn = 0; devfn < 0x100; devfn++) {
  260. u8 __iomem *devbase = cfgspace + (devfn << 8);
  261. u8 hdr_type = readb(devbase + PCI_HEADER_TYPE);
  262. u32 l = readl(devbase + PCI_VENDOR_ID);
  263. u16 s;
  264. DBG("devfn %x, l: %x\n", devfn, l);
  265. /* If no device, skip */
  266. if (l == 0xffffffff || l == 0x00000000 ||
  267. l == 0x0000ffff || l == 0xffff0000)
  268. goto next;
  269. /* Check if is supports capability lists */
  270. s = readw(devbase + PCI_STATUS);
  271. if (!(s & PCI_STATUS_CAP_LIST))
  272. goto next;
  273. mpic_scan_ht_pic(mpic, devbase, devfn, l);
  274. next:
  275. /* next device, if function 0 */
  276. if (PCI_FUNC(devfn) == 0 && (hdr_type & 0x80) == 0)
  277. devfn += 7;
  278. }
  279. }
  280. #endif /* CONFIG_MPIC_BROKEN_U3 */
  281. #define mpic_irq_to_hw(virq) ((unsigned int)irq_map[virq].hwirq)
  282. /* Find an mpic associated with a given linux interrupt */
  283. static struct mpic *mpic_find(unsigned int irq, unsigned int *is_ipi)
  284. {
  285. unsigned int src = mpic_irq_to_hw(irq);
  286. if (irq < NUM_ISA_INTERRUPTS)
  287. return NULL;
  288. if (is_ipi)
  289. *is_ipi = (src >= MPIC_VEC_IPI_0 && src <= MPIC_VEC_IPI_3);
  290. return irq_desc[irq].chip_data;
  291. }
  292. /* Convert a cpu mask from logical to physical cpu numbers. */
  293. static inline u32 mpic_physmask(u32 cpumask)
  294. {
  295. int i;
  296. u32 mask = 0;
  297. for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
  298. mask |= (cpumask & 1) << get_hard_smp_processor_id(i);
  299. return mask;
  300. }
  301. #ifdef CONFIG_SMP
  302. /* Get the mpic structure from the IPI number */
  303. static inline struct mpic * mpic_from_ipi(unsigned int ipi)
  304. {
  305. return irq_desc[ipi].chip_data;
  306. }
  307. #endif
  308. /* Get the mpic structure from the irq number */
  309. static inline struct mpic * mpic_from_irq(unsigned int irq)
  310. {
  311. return irq_desc[irq].chip_data;
  312. }
  313. /* Send an EOI */
  314. static inline void mpic_eoi(struct mpic *mpic)
  315. {
  316. mpic_cpu_write(MPIC_CPU_EOI, 0);
  317. (void)mpic_cpu_read(MPIC_CPU_WHOAMI);
  318. }
  319. #ifdef CONFIG_SMP
  320. static irqreturn_t mpic_ipi_action(int irq, void *dev_id, struct pt_regs *regs)
  321. {
  322. smp_message_recv(mpic_irq_to_hw(irq) - MPIC_VEC_IPI_0, regs);
  323. return IRQ_HANDLED;
  324. }
  325. #endif /* CONFIG_SMP */
  326. /*
  327. * Linux descriptor level callbacks
  328. */
  329. static void mpic_unmask_irq(unsigned int irq)
  330. {
  331. unsigned int loops = 100000;
  332. struct mpic *mpic = mpic_from_irq(irq);
  333. unsigned int src = mpic_irq_to_hw(irq);
  334. DBG("%p: %s: enable_irq: %d (src %d)\n", mpic, mpic->name, irq, src);
  335. mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
  336. mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) &
  337. ~MPIC_VECPRI_MASK);
  338. /* make sure mask gets to controller before we return to user */
  339. do {
  340. if (!loops--) {
  341. printk(KERN_ERR "mpic_enable_irq timeout\n");
  342. break;
  343. }
  344. } while(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK);
  345. }
  346. static void mpic_mask_irq(unsigned int irq)
  347. {
  348. unsigned int loops = 100000;
  349. struct mpic *mpic = mpic_from_irq(irq);
  350. unsigned int src = mpic_irq_to_hw(irq);
  351. DBG("%s: disable_irq: %d (src %d)\n", mpic->name, irq, src);
  352. mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
  353. mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) |
  354. MPIC_VECPRI_MASK);
  355. /* make sure mask gets to controller before we return to user */
  356. do {
  357. if (!loops--) {
  358. printk(KERN_ERR "mpic_enable_irq timeout\n");
  359. break;
  360. }
  361. } while(!(mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI) & MPIC_VECPRI_MASK));
  362. }
  363. static void mpic_end_irq(unsigned int irq)
  364. {
  365. struct mpic *mpic = mpic_from_irq(irq);
  366. #ifdef DEBUG_IRQ
  367. DBG("%s: end_irq: %d\n", mpic->name, irq);
  368. #endif
  369. /* We always EOI on end_irq() even for edge interrupts since that
  370. * should only lower the priority, the MPIC should have properly
  371. * latched another edge interrupt coming in anyway
  372. */
  373. mpic_eoi(mpic);
  374. }
  375. #ifdef CONFIG_MPIC_BROKEN_U3
  376. static void mpic_unmask_ht_irq(unsigned int irq)
  377. {
  378. struct mpic *mpic = mpic_from_irq(irq);
  379. unsigned int src = mpic_irq_to_hw(irq);
  380. mpic_unmask_irq(irq);
  381. if (irq_desc[irq].status & IRQ_LEVEL)
  382. mpic_ht_end_irq(mpic, src);
  383. }
  384. static unsigned int mpic_startup_ht_irq(unsigned int irq)
  385. {
  386. struct mpic *mpic = mpic_from_irq(irq);
  387. unsigned int src = mpic_irq_to_hw(irq);
  388. mpic_unmask_irq(irq);
  389. mpic_startup_ht_interrupt(mpic, src, irq_desc[irq].status);
  390. return 0;
  391. }
  392. static void mpic_shutdown_ht_irq(unsigned int irq)
  393. {
  394. struct mpic *mpic = mpic_from_irq(irq);
  395. unsigned int src = mpic_irq_to_hw(irq);
  396. mpic_shutdown_ht_interrupt(mpic, src, irq_desc[irq].status);
  397. mpic_mask_irq(irq);
  398. }
  399. static void mpic_end_ht_irq(unsigned int irq)
  400. {
  401. struct mpic *mpic = mpic_from_irq(irq);
  402. unsigned int src = mpic_irq_to_hw(irq);
  403. #ifdef DEBUG_IRQ
  404. DBG("%s: end_irq: %d\n", mpic->name, irq);
  405. #endif
  406. /* We always EOI on end_irq() even for edge interrupts since that
  407. * should only lower the priority, the MPIC should have properly
  408. * latched another edge interrupt coming in anyway
  409. */
  410. if (irq_desc[irq].status & IRQ_LEVEL)
  411. mpic_ht_end_irq(mpic, src);
  412. mpic_eoi(mpic);
  413. }
  414. #endif /* CONFIG_MPIC_BROKEN_U3 */
  415. #ifdef CONFIG_SMP
  416. static void mpic_unmask_ipi(unsigned int irq)
  417. {
  418. struct mpic *mpic = mpic_from_ipi(irq);
  419. unsigned int src = mpic_irq_to_hw(irq) - MPIC_VEC_IPI_0;
  420. DBG("%s: enable_ipi: %d (ipi %d)\n", mpic->name, irq, src);
  421. mpic_ipi_write(src, mpic_ipi_read(src) & ~MPIC_VECPRI_MASK);
  422. }
  423. static void mpic_mask_ipi(unsigned int irq)
  424. {
  425. /* NEVER disable an IPI... that's just plain wrong! */
  426. }
  427. static void mpic_end_ipi(unsigned int irq)
  428. {
  429. struct mpic *mpic = mpic_from_ipi(irq);
  430. /*
  431. * IPIs are marked IRQ_PER_CPU. This has the side effect of
  432. * preventing the IRQ_PENDING/IRQ_INPROGRESS logic from
  433. * applying to them. We EOI them late to avoid re-entering.
  434. * We mark IPI's with IRQF_DISABLED as they must run with
  435. * irqs disabled.
  436. */
  437. mpic_eoi(mpic);
  438. }
  439. #endif /* CONFIG_SMP */
  440. static void mpic_set_affinity(unsigned int irq, cpumask_t cpumask)
  441. {
  442. struct mpic *mpic = mpic_from_irq(irq);
  443. unsigned int src = mpic_irq_to_hw(irq);
  444. cpumask_t tmp;
  445. cpus_and(tmp, cpumask, cpu_online_map);
  446. mpic_irq_write(src, MPIC_IRQ_DESTINATION,
  447. mpic_physmask(cpus_addr(tmp)[0]));
  448. }
  449. static unsigned int mpic_flags_to_vecpri(unsigned int flags, int *level)
  450. {
  451. unsigned int vecpri;
  452. /* Now convert sense value */
  453. switch(flags & IRQ_TYPE_SENSE_MASK) {
  454. case IRQ_TYPE_EDGE_RISING:
  455. vecpri = MPIC_VECPRI_SENSE_EDGE |
  456. MPIC_VECPRI_POLARITY_POSITIVE;
  457. *level = 0;
  458. break;
  459. case IRQ_TYPE_EDGE_FALLING:
  460. vecpri = MPIC_VECPRI_SENSE_EDGE |
  461. MPIC_VECPRI_POLARITY_NEGATIVE;
  462. *level = 0;
  463. break;
  464. case IRQ_TYPE_LEVEL_HIGH:
  465. vecpri = MPIC_VECPRI_SENSE_LEVEL |
  466. MPIC_VECPRI_POLARITY_POSITIVE;
  467. *level = 1;
  468. break;
  469. case IRQ_TYPE_LEVEL_LOW:
  470. default:
  471. vecpri = MPIC_VECPRI_SENSE_LEVEL |
  472. MPIC_VECPRI_POLARITY_NEGATIVE;
  473. *level = 1;
  474. }
  475. return vecpri;
  476. }
  477. static struct irq_chip mpic_irq_chip = {
  478. .mask = mpic_mask_irq,
  479. .unmask = mpic_unmask_irq,
  480. .eoi = mpic_end_irq,
  481. };
  482. #ifdef CONFIG_SMP
  483. static struct irq_chip mpic_ipi_chip = {
  484. .mask = mpic_mask_ipi,
  485. .unmask = mpic_unmask_ipi,
  486. .eoi = mpic_end_ipi,
  487. };
  488. #endif /* CONFIG_SMP */
  489. #ifdef CONFIG_MPIC_BROKEN_U3
  490. static struct irq_chip mpic_irq_ht_chip = {
  491. .startup = mpic_startup_ht_irq,
  492. .shutdown = mpic_shutdown_ht_irq,
  493. .mask = mpic_mask_irq,
  494. .unmask = mpic_unmask_ht_irq,
  495. .eoi = mpic_end_ht_irq,
  496. };
  497. #endif /* CONFIG_MPIC_BROKEN_U3 */
  498. static int mpic_host_match(struct irq_host *h, struct device_node *node)
  499. {
  500. struct mpic *mpic = h->host_data;
  501. /* Exact match, unless mpic node is NULL */
  502. return mpic->of_node == NULL || mpic->of_node == node;
  503. }
  504. static int mpic_host_map(struct irq_host *h, unsigned int virq,
  505. irq_hw_number_t hw, unsigned int flags)
  506. {
  507. struct irq_desc *desc = get_irq_desc(virq);
  508. struct irq_chip *chip;
  509. struct mpic *mpic = h->host_data;
  510. unsigned int vecpri = MPIC_VECPRI_SENSE_LEVEL |
  511. MPIC_VECPRI_POLARITY_NEGATIVE;
  512. int level;
  513. pr_debug("mpic: map virq %d, hwirq 0x%lx, flags: 0x%x\n",
  514. virq, hw, flags);
  515. if (hw == MPIC_VEC_SPURRIOUS)
  516. return -EINVAL;
  517. #ifdef CONFIG_SMP
  518. else if (hw >= MPIC_VEC_IPI_0) {
  519. WARN_ON(!(mpic->flags & MPIC_PRIMARY));
  520. pr_debug("mpic: mapping as IPI\n");
  521. set_irq_chip_data(virq, mpic);
  522. set_irq_chip_and_handler(virq, &mpic->hc_ipi,
  523. handle_percpu_irq);
  524. return 0;
  525. }
  526. #endif /* CONFIG_SMP */
  527. if (hw >= mpic->irq_count)
  528. return -EINVAL;
  529. /* If no sense provided, check default sense array */
  530. if (((flags & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_NONE) &&
  531. mpic->senses && hw < mpic->senses_count)
  532. flags |= mpic->senses[hw];
  533. vecpri = mpic_flags_to_vecpri(flags, &level);
  534. if (level)
  535. desc->status |= IRQ_LEVEL;
  536. chip = &mpic->hc_irq;
  537. #ifdef CONFIG_MPIC_BROKEN_U3
  538. /* Check for HT interrupts, override vecpri */
  539. if (mpic_is_ht_interrupt(mpic, hw)) {
  540. vecpri &= ~(MPIC_VECPRI_SENSE_MASK |
  541. MPIC_VECPRI_POLARITY_MASK);
  542. vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
  543. chip = &mpic->hc_ht_irq;
  544. }
  545. #endif
  546. /* Reconfigure irq */
  547. vecpri |= MPIC_VECPRI_MASK | hw | (8 << MPIC_VECPRI_PRIORITY_SHIFT);
  548. mpic_irq_write(hw, MPIC_IRQ_VECTOR_PRI, vecpri);
  549. pr_debug("mpic: mapping as IRQ\n");
  550. set_irq_chip_data(virq, mpic);
  551. set_irq_chip_and_handler(virq, chip, handle_fasteoi_irq);
  552. return 0;
  553. }
  554. static int mpic_host_xlate(struct irq_host *h, struct device_node *ct,
  555. u32 *intspec, unsigned int intsize,
  556. irq_hw_number_t *out_hwirq, unsigned int *out_flags)
  557. {
  558. static unsigned char map_mpic_senses[4] = {
  559. IRQ_TYPE_EDGE_RISING,
  560. IRQ_TYPE_LEVEL_LOW,
  561. IRQ_TYPE_LEVEL_HIGH,
  562. IRQ_TYPE_EDGE_FALLING,
  563. };
  564. *out_hwirq = intspec[0];
  565. if (intsize > 1 && intspec[1] < 4)
  566. *out_flags = map_mpic_senses[intspec[1]];
  567. else
  568. *out_flags = IRQ_TYPE_NONE;
  569. return 0;
  570. }
  571. static struct irq_host_ops mpic_host_ops = {
  572. .match = mpic_host_match,
  573. .map = mpic_host_map,
  574. .xlate = mpic_host_xlate,
  575. };
  576. /*
  577. * Exported functions
  578. */
  579. struct mpic * __init mpic_alloc(struct device_node *node,
  580. unsigned long phys_addr,
  581. unsigned int flags,
  582. unsigned int isu_size,
  583. unsigned int irq_count,
  584. const char *name)
  585. {
  586. struct mpic *mpic;
  587. u32 reg;
  588. const char *vers;
  589. int i;
  590. mpic = alloc_bootmem(sizeof(struct mpic));
  591. if (mpic == NULL)
  592. return NULL;
  593. memset(mpic, 0, sizeof(struct mpic));
  594. mpic->name = name;
  595. mpic->of_node = node ? of_node_get(node) : NULL;
  596. mpic->irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR, 256,
  597. &mpic_host_ops,
  598. MPIC_VEC_SPURRIOUS);
  599. if (mpic->irqhost == NULL) {
  600. of_node_put(node);
  601. return NULL;
  602. }
  603. mpic->irqhost->host_data = mpic;
  604. mpic->hc_irq = mpic_irq_chip;
  605. mpic->hc_irq.typename = name;
  606. if (flags & MPIC_PRIMARY)
  607. mpic->hc_irq.set_affinity = mpic_set_affinity;
  608. #ifdef CONFIG_MPIC_BROKEN_U3
  609. mpic->hc_ht_irq = mpic_irq_ht_chip;
  610. mpic->hc_ht_irq.typename = name;
  611. if (flags & MPIC_PRIMARY)
  612. mpic->hc_ht_irq.set_affinity = mpic_set_affinity;
  613. #endif /* CONFIG_MPIC_BROKEN_U3 */
  614. #ifdef CONFIG_SMP
  615. mpic->hc_ipi = mpic_ipi_chip;
  616. mpic->hc_ipi.typename = name;
  617. #endif /* CONFIG_SMP */
  618. mpic->flags = flags;
  619. mpic->isu_size = isu_size;
  620. mpic->irq_count = irq_count;
  621. mpic->num_sources = 0; /* so far */
  622. /* Map the global registers */
  623. mpic->gregs = ioremap(phys_addr + MPIC_GREG_BASE, 0x1000);
  624. mpic->tmregs = mpic->gregs + ((MPIC_TIMER_BASE - MPIC_GREG_BASE) >> 2);
  625. BUG_ON(mpic->gregs == NULL);
  626. /* Reset */
  627. if (flags & MPIC_WANTS_RESET) {
  628. mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0,
  629. mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
  630. | MPIC_GREG_GCONF_RESET);
  631. while( mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
  632. & MPIC_GREG_GCONF_RESET)
  633. mb();
  634. }
  635. /* Read feature register, calculate num CPUs and, for non-ISU
  636. * MPICs, num sources as well. On ISU MPICs, sources are counted
  637. * as ISUs are added
  638. */
  639. reg = mpic_read(mpic->gregs, MPIC_GREG_FEATURE_0);
  640. mpic->num_cpus = ((reg & MPIC_GREG_FEATURE_LAST_CPU_MASK)
  641. >> MPIC_GREG_FEATURE_LAST_CPU_SHIFT) + 1;
  642. if (isu_size == 0)
  643. mpic->num_sources = ((reg & MPIC_GREG_FEATURE_LAST_SRC_MASK)
  644. >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT) + 1;
  645. /* Map the per-CPU registers */
  646. for (i = 0; i < mpic->num_cpus; i++) {
  647. mpic->cpuregs[i] = ioremap(phys_addr + MPIC_CPU_BASE +
  648. i * MPIC_CPU_STRIDE, 0x1000);
  649. BUG_ON(mpic->cpuregs[i] == NULL);
  650. }
  651. /* Initialize main ISU if none provided */
  652. if (mpic->isu_size == 0) {
  653. mpic->isu_size = mpic->num_sources;
  654. mpic->isus[0] = ioremap(phys_addr + MPIC_IRQ_BASE,
  655. MPIC_IRQ_STRIDE * mpic->isu_size);
  656. BUG_ON(mpic->isus[0] == NULL);
  657. }
  658. mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
  659. mpic->isu_mask = (1 << mpic->isu_shift) - 1;
  660. /* Display version */
  661. switch (reg & MPIC_GREG_FEATURE_VERSION_MASK) {
  662. case 1:
  663. vers = "1.0";
  664. break;
  665. case 2:
  666. vers = "1.2";
  667. break;
  668. case 3:
  669. vers = "1.3";
  670. break;
  671. default:
  672. vers = "<unknown>";
  673. break;
  674. }
  675. printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %lx, max %d CPUs\n",
  676. name, vers, phys_addr, mpic->num_cpus);
  677. printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n", mpic->isu_size,
  678. mpic->isu_shift, mpic->isu_mask);
  679. mpic->next = mpics;
  680. mpics = mpic;
  681. if (flags & MPIC_PRIMARY) {
  682. mpic_primary = mpic;
  683. irq_set_default_host(mpic->irqhost);
  684. }
  685. return mpic;
  686. }
  687. void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
  688. unsigned long phys_addr)
  689. {
  690. unsigned int isu_first = isu_num * mpic->isu_size;
  691. BUG_ON(isu_num >= MPIC_MAX_ISU);
  692. mpic->isus[isu_num] = ioremap(phys_addr, MPIC_IRQ_STRIDE * mpic->isu_size);
  693. if ((isu_first + mpic->isu_size) > mpic->num_sources)
  694. mpic->num_sources = isu_first + mpic->isu_size;
  695. }
  696. void __init mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count)
  697. {
  698. mpic->senses = senses;
  699. mpic->senses_count = count;
  700. }
  701. void __init mpic_init(struct mpic *mpic)
  702. {
  703. int i;
  704. BUG_ON(mpic->num_sources == 0);
  705. WARN_ON(mpic->num_sources > MPIC_VEC_IPI_0);
  706. /* Sanitize source count */
  707. if (mpic->num_sources > MPIC_VEC_IPI_0)
  708. mpic->num_sources = MPIC_VEC_IPI_0;
  709. printk(KERN_INFO "mpic: Initializing for %d sources\n", mpic->num_sources);
  710. /* Set current processor priority to max */
  711. mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0xf);
  712. /* Initialize timers: just disable them all */
  713. for (i = 0; i < 4; i++) {
  714. mpic_write(mpic->tmregs,
  715. i * MPIC_TIMER_STRIDE + MPIC_TIMER_DESTINATION, 0);
  716. mpic_write(mpic->tmregs,
  717. i * MPIC_TIMER_STRIDE + MPIC_TIMER_VECTOR_PRI,
  718. MPIC_VECPRI_MASK |
  719. (MPIC_VEC_TIMER_0 + i));
  720. }
  721. /* Initialize IPIs to our reserved vectors and mark them disabled for now */
  722. mpic_test_broken_ipi(mpic);
  723. for (i = 0; i < 4; i++) {
  724. mpic_ipi_write(i,
  725. MPIC_VECPRI_MASK |
  726. (10 << MPIC_VECPRI_PRIORITY_SHIFT) |
  727. (MPIC_VEC_IPI_0 + i));
  728. }
  729. /* Initialize interrupt sources */
  730. if (mpic->irq_count == 0)
  731. mpic->irq_count = mpic->num_sources;
  732. #ifdef CONFIG_MPIC_BROKEN_U3
  733. /* Do the HT PIC fixups on U3 broken mpic */
  734. DBG("MPIC flags: %x\n", mpic->flags);
  735. if ((mpic->flags & MPIC_BROKEN_U3) && (mpic->flags & MPIC_PRIMARY))
  736. mpic_scan_ht_pics(mpic);
  737. #endif /* CONFIG_MPIC_BROKEN_U3 */
  738. for (i = 0; i < mpic->num_sources; i++) {
  739. /* start with vector = source number, and masked */
  740. u32 vecpri = MPIC_VECPRI_MASK | i | (8 << MPIC_VECPRI_PRIORITY_SHIFT);
  741. int level = 1;
  742. /* do senses munging */
  743. if (mpic->senses && i < mpic->senses_count)
  744. vecpri = mpic_flags_to_vecpri(mpic->senses[i],
  745. &level);
  746. else
  747. vecpri |= MPIC_VECPRI_SENSE_LEVEL;
  748. /* deal with broken U3 */
  749. if (mpic->flags & MPIC_BROKEN_U3) {
  750. #ifdef CONFIG_MPIC_BROKEN_U3
  751. if (mpic_is_ht_interrupt(mpic, i)) {
  752. vecpri &= ~(MPIC_VECPRI_SENSE_MASK |
  753. MPIC_VECPRI_POLARITY_MASK);
  754. vecpri |= MPIC_VECPRI_POLARITY_POSITIVE;
  755. }
  756. #else
  757. printk(KERN_ERR "mpic: BROKEN_U3 set, but CONFIG doesn't match\n");
  758. #endif
  759. }
  760. DBG("setup source %d, vecpri: %08x, level: %d\n", i, vecpri,
  761. (level != 0));
  762. /* init hw */
  763. mpic_irq_write(i, MPIC_IRQ_VECTOR_PRI, vecpri);
  764. mpic_irq_write(i, MPIC_IRQ_DESTINATION,
  765. 1 << hard_smp_processor_id());
  766. }
  767. /* Init spurrious vector */
  768. mpic_write(mpic->gregs, MPIC_GREG_SPURIOUS, MPIC_VEC_SPURRIOUS);
  769. /* Disable 8259 passthrough */
  770. mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0,
  771. mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_0)
  772. | MPIC_GREG_GCONF_8259_PTHROU_DIS);
  773. /* Set current processor priority to 0 */
  774. mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
  775. }
  776. void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio)
  777. {
  778. u32 v;
  779. v = mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_1);
  780. v &= ~MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK;
  781. v |= MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO(clock_ratio);
  782. mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_1, v);
  783. }
  784. void __init mpic_set_serial_int(struct mpic *mpic, int enable)
  785. {
  786. u32 v;
  787. v = mpic_read(mpic->gregs, MPIC_GREG_GLOBAL_CONF_1);
  788. if (enable)
  789. v |= MPIC_GREG_GLOBAL_CONF_1_SIE;
  790. else
  791. v &= ~MPIC_GREG_GLOBAL_CONF_1_SIE;
  792. mpic_write(mpic->gregs, MPIC_GREG_GLOBAL_CONF_1, v);
  793. }
  794. void mpic_irq_set_priority(unsigned int irq, unsigned int pri)
  795. {
  796. int is_ipi;
  797. struct mpic *mpic = mpic_find(irq, &is_ipi);
  798. unsigned int src = mpic_irq_to_hw(irq);
  799. unsigned long flags;
  800. u32 reg;
  801. spin_lock_irqsave(&mpic_lock, flags);
  802. if (is_ipi) {
  803. reg = mpic_ipi_read(src - MPIC_VEC_IPI_0) &
  804. ~MPIC_VECPRI_PRIORITY_MASK;
  805. mpic_ipi_write(src - MPIC_VEC_IPI_0,
  806. reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
  807. } else {
  808. reg = mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI)
  809. & ~MPIC_VECPRI_PRIORITY_MASK;
  810. mpic_irq_write(src, MPIC_IRQ_VECTOR_PRI,
  811. reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
  812. }
  813. spin_unlock_irqrestore(&mpic_lock, flags);
  814. }
  815. unsigned int mpic_irq_get_priority(unsigned int irq)
  816. {
  817. int is_ipi;
  818. struct mpic *mpic = mpic_find(irq, &is_ipi);
  819. unsigned int src = mpic_irq_to_hw(irq);
  820. unsigned long flags;
  821. u32 reg;
  822. spin_lock_irqsave(&mpic_lock, flags);
  823. if (is_ipi)
  824. reg = mpic_ipi_read(src = MPIC_VEC_IPI_0);
  825. else
  826. reg = mpic_irq_read(src, MPIC_IRQ_VECTOR_PRI);
  827. spin_unlock_irqrestore(&mpic_lock, flags);
  828. return (reg & MPIC_VECPRI_PRIORITY_MASK) >> MPIC_VECPRI_PRIORITY_SHIFT;
  829. }
  830. void mpic_setup_this_cpu(void)
  831. {
  832. #ifdef CONFIG_SMP
  833. struct mpic *mpic = mpic_primary;
  834. unsigned long flags;
  835. u32 msk = 1 << hard_smp_processor_id();
  836. unsigned int i;
  837. BUG_ON(mpic == NULL);
  838. DBG("%s: setup_this_cpu(%d)\n", mpic->name, hard_smp_processor_id());
  839. spin_lock_irqsave(&mpic_lock, flags);
  840. /* let the mpic know we want intrs. default affinity is 0xffffffff
  841. * until changed via /proc. That's how it's done on x86. If we want
  842. * it differently, then we should make sure we also change the default
  843. * values of irq_desc[].affinity in irq.c.
  844. */
  845. if (distribute_irqs) {
  846. for (i = 0; i < mpic->num_sources ; i++)
  847. mpic_irq_write(i, MPIC_IRQ_DESTINATION,
  848. mpic_irq_read(i, MPIC_IRQ_DESTINATION) | msk);
  849. }
  850. /* Set current processor priority to 0 */
  851. mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
  852. spin_unlock_irqrestore(&mpic_lock, flags);
  853. #endif /* CONFIG_SMP */
  854. }
  855. int mpic_cpu_get_priority(void)
  856. {
  857. struct mpic *mpic = mpic_primary;
  858. return mpic_cpu_read(MPIC_CPU_CURRENT_TASK_PRI);
  859. }
  860. void mpic_cpu_set_priority(int prio)
  861. {
  862. struct mpic *mpic = mpic_primary;
  863. prio &= MPIC_CPU_TASKPRI_MASK;
  864. mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, prio);
  865. }
  866. /*
  867. * XXX: someone who knows mpic should check this.
  868. * do we need to eoi the ipi including for kexec cpu here (see xics comments)?
  869. * or can we reset the mpic in the new kernel?
  870. */
  871. void mpic_teardown_this_cpu(int secondary)
  872. {
  873. struct mpic *mpic = mpic_primary;
  874. unsigned long flags;
  875. u32 msk = 1 << hard_smp_processor_id();
  876. unsigned int i;
  877. BUG_ON(mpic == NULL);
  878. DBG("%s: teardown_this_cpu(%d)\n", mpic->name, hard_smp_processor_id());
  879. spin_lock_irqsave(&mpic_lock, flags);
  880. /* let the mpic know we don't want intrs. */
  881. for (i = 0; i < mpic->num_sources ; i++)
  882. mpic_irq_write(i, MPIC_IRQ_DESTINATION,
  883. mpic_irq_read(i, MPIC_IRQ_DESTINATION) & ~msk);
  884. /* Set current processor priority to max */
  885. mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0xf);
  886. spin_unlock_irqrestore(&mpic_lock, flags);
  887. }
  888. void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask)
  889. {
  890. struct mpic *mpic = mpic_primary;
  891. BUG_ON(mpic == NULL);
  892. #ifdef DEBUG_IPI
  893. DBG("%s: send_ipi(ipi_no: %d)\n", mpic->name, ipi_no);
  894. #endif
  895. mpic_cpu_write(MPIC_CPU_IPI_DISPATCH_0 + ipi_no * 0x10,
  896. mpic_physmask(cpu_mask & cpus_addr(cpu_online_map)[0]));
  897. }
  898. unsigned int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs)
  899. {
  900. u32 src;
  901. src = mpic_cpu_read(MPIC_CPU_INTACK) & MPIC_VECPRI_VECTOR_MASK;
  902. #ifdef DEBUG_LOW
  903. DBG("%s: get_one_irq(): %d\n", mpic->name, src);
  904. #endif
  905. if (unlikely(src == MPIC_VEC_SPURRIOUS))
  906. return NO_IRQ;
  907. return irq_linear_revmap(mpic->irqhost, src);
  908. }
  909. unsigned int mpic_get_irq(struct pt_regs *regs)
  910. {
  911. struct mpic *mpic = mpic_primary;
  912. BUG_ON(mpic == NULL);
  913. return mpic_get_one_irq(mpic, regs);
  914. }
  915. #ifdef CONFIG_SMP
  916. void mpic_request_ipis(void)
  917. {
  918. struct mpic *mpic = mpic_primary;
  919. int i;
  920. static char *ipi_names[] = {
  921. "IPI0 (call function)",
  922. "IPI1 (reschedule)",
  923. "IPI2 (unused)",
  924. "IPI3 (debugger break)",
  925. };
  926. BUG_ON(mpic == NULL);
  927. printk(KERN_INFO "mpic: requesting IPIs ... \n");
  928. for (i = 0; i < 4; i++) {
  929. unsigned int vipi = irq_create_mapping(mpic->irqhost,
  930. MPIC_VEC_IPI_0 + i, 0);
  931. if (vipi == NO_IRQ) {
  932. printk(KERN_ERR "Failed to map IPI %d\n", i);
  933. break;
  934. }
  935. request_irq(vipi, mpic_ipi_action, IRQF_DISABLED,
  936. ipi_names[i], mpic);
  937. }
  938. }
  939. void smp_mpic_message_pass(int target, int msg)
  940. {
  941. /* make sure we're sending something that translates to an IPI */
  942. if ((unsigned int)msg > 3) {
  943. printk("SMP %d: smp_message_pass: unknown msg %d\n",
  944. smp_processor_id(), msg);
  945. return;
  946. }
  947. switch (target) {
  948. case MSG_ALL:
  949. mpic_send_ipi(msg, 0xffffffff);
  950. break;
  951. case MSG_ALL_BUT_SELF:
  952. mpic_send_ipi(msg, 0xffffffff & ~(1 << smp_processor_id()));
  953. break;
  954. default:
  955. mpic_send_ipi(msg, 1 << target);
  956. break;
  957. }
  958. }
  959. #endif /* CONFIG_SMP */