mpc52xx_pic.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. *
  3. * Programmable Interrupt Controller functions for the Freescale MPC52xx.
  4. *
  5. * Copyright (C) 2008 Secret Lab Technologies Ltd.
  6. * Copyright (C) 2006 bplan GmbH
  7. * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
  8. * Copyright (C) 2003 Montavista Software, Inc
  9. *
  10. * Based on the code from the 2.4 kernel by
  11. * Dale Farnsworth <dfarnsworth@mvista.com> and Kent Borg.
  12. *
  13. * This file is licensed under the terms of the GNU General Public License
  14. * version 2. This program is licensed "as is" without any warranty of any
  15. * kind, whether express or implied.
  16. *
  17. */
  18. /*
  19. * This is the device driver for the MPC5200 interrupt controller.
  20. *
  21. * hardware overview
  22. * -----------------
  23. * The MPC5200 interrupt controller groups the all interrupt sources into
  24. * three groups called 'critical', 'main', and 'peripheral'. The critical
  25. * group has 3 irqs, External IRQ0, slice timer 0 irq, and wake from deep
  26. * sleep. Main group include the other 3 external IRQs, slice timer 1, RTC,
  27. * gpios, and the general purpose timers. Peripheral group contains the
  28. * remaining irq sources from all of the on-chip peripherals (PSCs, Ethernet,
  29. * USB, DMA, etc).
  30. *
  31. * virqs
  32. * -----
  33. * The Linux IRQ subsystem requires that each irq source be assigned a
  34. * system wide unique IRQ number starting at 1 (0 means no irq). Since
  35. * systems can have multiple interrupt controllers, the virtual IRQ (virq)
  36. * infrastructure lets each interrupt controller to define a local set
  37. * of IRQ numbers and the virq infrastructure maps those numbers into
  38. * a unique range of the global IRQ# space.
  39. *
  40. * To define a range of virq numbers for this controller, this driver first
  41. * assigns a number to each of the irq groups (called the level 1 or L1
  42. * value). Within each group individual irq sources are also assigned a
  43. * number, as defined by the MPC5200 user guide, and refers to it as the
  44. * level 2 or L2 value. The virq number is determined by shifting up the
  45. * L1 value by MPC52xx_IRQ_L1_OFFSET and ORing it with the L2 value.
  46. *
  47. * For example, the TMR0 interrupt is irq 9 in the main group. The
  48. * virq for TMR0 is calculated by ((1 << MPC52xx_IRQ_L1_OFFSET) | 9).
  49. *
  50. * The observant reader will also notice that this driver defines a 4th
  51. * interrupt group called 'bestcomm'. The bestcomm group isn't physically
  52. * part of the MPC5200 interrupt controller, but it is used here to assign
  53. * a separate virq number for each bestcomm task (since any of the 16
  54. * bestcomm tasks can cause the bestcomm interrupt to be raised). When a
  55. * bestcomm interrupt occurs (peripheral group, irq 0) this driver determines
  56. * which task needs servicing and returns the irq number for that task. This
  57. * allows drivers which use bestcomm to define their own interrupt handlers.
  58. *
  59. * irq_chip structures
  60. * -------------------
  61. * For actually manipulating IRQs (masking, enabling, clearing, etc) this
  62. * driver defines four separate 'irq_chip' structures, one for the main
  63. * group, one for the peripherals group, one for the bestcomm group and one
  64. * for external interrupts. The irq_chip structures provide the hooks needed
  65. * to manipulate each IRQ source, and since each group is has a separate set
  66. * of registers for controlling the irq, it makes sense to divide up the
  67. * hooks along those lines.
  68. *
  69. * You'll notice that there is not an irq_chip for the critical group and
  70. * you'll also notice that there is an irq_chip defined for external
  71. * interrupts even though there is no external interrupt group. The reason
  72. * for this is that the four external interrupts are all managed with the same
  73. * register even though one of the external IRQs is in the critical group and
  74. * the other three are in the main group. For this reason it makes sense for
  75. * the 4 external irqs to be managed using a separate set of hooks. The
  76. * reason there is no crit irq_chip is that of the 3 irqs in the critical
  77. * group, only external interrupt is actually support at this time by this
  78. * driver and since external interrupt is the only one used, it can just
  79. * be directed to make use of the external irq irq_chip.
  80. *
  81. * device tree bindings
  82. * --------------------
  83. * The device tree bindings for this controller reflect the two level
  84. * organization of irqs in the device. #interrupt-cells = <3> where the
  85. * first cell is the group number [0..3], the second cell is the irq
  86. * number in the group, and the third cell is the sense type (level/edge).
  87. * For reference, the following is a list of the interrupt property values
  88. * associated with external interrupt sources on the MPC5200 (just because
  89. * it is non-obvious to determine what the interrupts property should be
  90. * when reading the mpc5200 manual and it is a frequently asked question).
  91. *
  92. * External interrupts:
  93. * <0 0 n> external irq0, n is sense (n=0: level high,
  94. * <1 1 n> external irq1, n is sense n=1: edge rising,
  95. * <1 2 n> external irq2, n is sense n=2: edge falling,
  96. * <1 3 n> external irq3, n is sense n=3: level low)
  97. */
  98. #undef DEBUG
  99. #include <linux/interrupt.h>
  100. #include <linux/irq.h>
  101. #include <linux/of.h>
  102. #include <asm/io.h>
  103. #include <asm/prom.h>
  104. #include <asm/mpc52xx.h>
  105. /* HW IRQ mapping */
  106. #define MPC52xx_IRQ_L1_CRIT (0)
  107. #define MPC52xx_IRQ_L1_MAIN (1)
  108. #define MPC52xx_IRQ_L1_PERP (2)
  109. #define MPC52xx_IRQ_L1_SDMA (3)
  110. #define MPC52xx_IRQ_L1_OFFSET (6)
  111. #define MPC52xx_IRQ_L1_MASK (0x00c0)
  112. #define MPC52xx_IRQ_L2_MASK (0x003f)
  113. #define MPC52xx_IRQ_HIGHTESTHWIRQ (0xd0)
  114. /* MPC5200 device tree match tables */
  115. static struct of_device_id mpc52xx_pic_ids[] __initdata = {
  116. { .compatible = "fsl,mpc5200-pic", },
  117. { .compatible = "mpc5200-pic", },
  118. {}
  119. };
  120. static struct of_device_id mpc52xx_sdma_ids[] __initdata = {
  121. { .compatible = "fsl,mpc5200-bestcomm", },
  122. { .compatible = "mpc5200-bestcomm", },
  123. {}
  124. };
  125. static struct mpc52xx_intr __iomem *intr;
  126. static struct mpc52xx_sdma __iomem *sdma;
  127. static struct irq_host *mpc52xx_irqhost = NULL;
  128. static unsigned char mpc52xx_map_senses[4] = {
  129. IRQ_TYPE_LEVEL_HIGH,
  130. IRQ_TYPE_EDGE_RISING,
  131. IRQ_TYPE_EDGE_FALLING,
  132. IRQ_TYPE_LEVEL_LOW,
  133. };
  134. /* Utility functions */
  135. static inline void io_be_setbit(u32 __iomem *addr, int bitno)
  136. {
  137. out_be32(addr, in_be32(addr) | (1 << bitno));
  138. }
  139. static inline void io_be_clrbit(u32 __iomem *addr, int bitno)
  140. {
  141. out_be32(addr, in_be32(addr) & ~(1 << bitno));
  142. }
  143. /*
  144. * IRQ[0-3] interrupt irq_chip
  145. */
  146. static void mpc52xx_extirq_mask(unsigned int virq)
  147. {
  148. int irq;
  149. int l2irq;
  150. irq = irq_map[virq].hwirq;
  151. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  152. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  153. io_be_clrbit(&intr->ctrl, 11 - l2irq);
  154. }
  155. static void mpc52xx_extirq_unmask(unsigned int virq)
  156. {
  157. int irq;
  158. int l2irq;
  159. irq = irq_map[virq].hwirq;
  160. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  161. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  162. io_be_setbit(&intr->ctrl, 11 - l2irq);
  163. }
  164. static void mpc52xx_extirq_ack(unsigned int virq)
  165. {
  166. int irq;
  167. int l2irq;
  168. irq = irq_map[virq].hwirq;
  169. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  170. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  171. io_be_setbit(&intr->ctrl, 27-l2irq);
  172. }
  173. static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type)
  174. {
  175. u32 ctrl_reg, type;
  176. int irq;
  177. int l2irq;
  178. irq = irq_map[virq].hwirq;
  179. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  180. pr_debug("%s: irq=%x. l2=%d flow_type=%d\n", __func__, irq, l2irq, flow_type);
  181. switch (flow_type) {
  182. case IRQF_TRIGGER_HIGH:
  183. type = 0;
  184. break;
  185. case IRQF_TRIGGER_RISING:
  186. type = 1;
  187. break;
  188. case IRQF_TRIGGER_FALLING:
  189. type = 2;
  190. break;
  191. case IRQF_TRIGGER_LOW:
  192. type = 3;
  193. break;
  194. default:
  195. type = 0;
  196. }
  197. ctrl_reg = in_be32(&intr->ctrl);
  198. ctrl_reg &= ~(0x3 << (22 - (l2irq * 2)));
  199. ctrl_reg |= (type << (22 - (l2irq * 2)));
  200. out_be32(&intr->ctrl, ctrl_reg);
  201. return 0;
  202. }
  203. static struct irq_chip mpc52xx_extirq_irqchip = {
  204. .typename = " MPC52xx IRQ[0-3] ",
  205. .mask = mpc52xx_extirq_mask,
  206. .unmask = mpc52xx_extirq_unmask,
  207. .ack = mpc52xx_extirq_ack,
  208. .set_type = mpc52xx_extirq_set_type,
  209. };
  210. /*
  211. * Main interrupt irq_chip
  212. */
  213. static void mpc52xx_main_mask(unsigned int virq)
  214. {
  215. int irq;
  216. int l2irq;
  217. irq = irq_map[virq].hwirq;
  218. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  219. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  220. io_be_setbit(&intr->main_mask, 16 - l2irq);
  221. }
  222. static void mpc52xx_main_unmask(unsigned int virq)
  223. {
  224. int irq;
  225. int l2irq;
  226. irq = irq_map[virq].hwirq;
  227. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  228. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  229. io_be_clrbit(&intr->main_mask, 16 - l2irq);
  230. }
  231. static struct irq_chip mpc52xx_main_irqchip = {
  232. .typename = "MPC52xx Main",
  233. .mask = mpc52xx_main_mask,
  234. .mask_ack = mpc52xx_main_mask,
  235. .unmask = mpc52xx_main_unmask,
  236. };
  237. /*
  238. * Peripherals interrupt irq_chip
  239. */
  240. static void mpc52xx_periph_mask(unsigned int virq)
  241. {
  242. int irq;
  243. int l2irq;
  244. irq = irq_map[virq].hwirq;
  245. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  246. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  247. io_be_setbit(&intr->per_mask, 31 - l2irq);
  248. }
  249. static void mpc52xx_periph_unmask(unsigned int virq)
  250. {
  251. int irq;
  252. int l2irq;
  253. irq = irq_map[virq].hwirq;
  254. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  255. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  256. io_be_clrbit(&intr->per_mask, 31 - l2irq);
  257. }
  258. static struct irq_chip mpc52xx_periph_irqchip = {
  259. .typename = "MPC52xx Peripherals",
  260. .mask = mpc52xx_periph_mask,
  261. .mask_ack = mpc52xx_periph_mask,
  262. .unmask = mpc52xx_periph_unmask,
  263. };
  264. /*
  265. * SDMA interrupt irq_chip
  266. */
  267. static void mpc52xx_sdma_mask(unsigned int virq)
  268. {
  269. int irq;
  270. int l2irq;
  271. irq = irq_map[virq].hwirq;
  272. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  273. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  274. io_be_setbit(&sdma->IntMask, l2irq);
  275. }
  276. static void mpc52xx_sdma_unmask(unsigned int virq)
  277. {
  278. int irq;
  279. int l2irq;
  280. irq = irq_map[virq].hwirq;
  281. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  282. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  283. io_be_clrbit(&sdma->IntMask, l2irq);
  284. }
  285. static void mpc52xx_sdma_ack(unsigned int virq)
  286. {
  287. int irq;
  288. int l2irq;
  289. irq = irq_map[virq].hwirq;
  290. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  291. pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
  292. out_be32(&sdma->IntPend, 1 << l2irq);
  293. }
  294. static struct irq_chip mpc52xx_sdma_irqchip = {
  295. .typename = "MPC52xx SDMA",
  296. .mask = mpc52xx_sdma_mask,
  297. .unmask = mpc52xx_sdma_unmask,
  298. .ack = mpc52xx_sdma_ack,
  299. };
  300. /**
  301. * mpc52xx_irqhost_xlate - translate virq# from device tree interrupts property
  302. */
  303. static int mpc52xx_irqhost_xlate(struct irq_host *h, struct device_node *ct,
  304. u32 *intspec, unsigned int intsize,
  305. irq_hw_number_t *out_hwirq,
  306. unsigned int *out_flags)
  307. {
  308. int intrvect_l1;
  309. int intrvect_l2;
  310. int intrvect_type;
  311. int intrvect_linux;
  312. if (intsize != 3)
  313. return -1;
  314. intrvect_l1 = (int)intspec[0];
  315. intrvect_l2 = (int)intspec[1];
  316. intrvect_type = (int)intspec[2];
  317. intrvect_linux = (intrvect_l1 << MPC52xx_IRQ_L1_OFFSET) &
  318. MPC52xx_IRQ_L1_MASK;
  319. intrvect_linux |= intrvect_l2 & MPC52xx_IRQ_L2_MASK;
  320. pr_debug("return %x, l1=%d, l2=%d\n", intrvect_linux, intrvect_l1,
  321. intrvect_l2);
  322. *out_hwirq = intrvect_linux;
  323. *out_flags = mpc52xx_map_senses[intrvect_type];
  324. return 0;
  325. }
  326. /**
  327. * mpc52xx_irqx_gettype - determine the IRQ sense type (level/edge)
  328. *
  329. * Only external IRQs need this.
  330. */
  331. static int mpc52xx_irqx_gettype(int irq)
  332. {
  333. int type;
  334. u32 ctrl_reg;
  335. ctrl_reg = in_be32(&intr->ctrl);
  336. type = (ctrl_reg >> (22 - irq * 2)) & 0x3;
  337. return mpc52xx_map_senses[type];
  338. }
  339. /**
  340. * mpc52xx_irqhost_map - Hook to map from virq to an irq_chip structure
  341. */
  342. static int mpc52xx_irqhost_map(struct irq_host *h, unsigned int virq,
  343. irq_hw_number_t irq)
  344. {
  345. int l1irq;
  346. int l2irq;
  347. struct irq_chip *good_irqchip;
  348. void *good_handle;
  349. int type;
  350. l1irq = (irq & MPC52xx_IRQ_L1_MASK) >> MPC52xx_IRQ_L1_OFFSET;
  351. l2irq = irq & MPC52xx_IRQ_L2_MASK;
  352. /*
  353. * Most of ours IRQs will be level low
  354. * Only external IRQs on some platform may be others
  355. */
  356. type = IRQ_TYPE_LEVEL_LOW;
  357. switch (l1irq) {
  358. case MPC52xx_IRQ_L1_CRIT:
  359. pr_debug("%s: Critical. l2=%x\n", __func__, l2irq);
  360. BUG_ON(l2irq != 0);
  361. type = mpc52xx_irqx_gettype(l2irq);
  362. good_irqchip = &mpc52xx_extirq_irqchip;
  363. break;
  364. case MPC52xx_IRQ_L1_MAIN:
  365. pr_debug("%s: Main IRQ[1-3] l2=%x\n", __func__, l2irq);
  366. if ((l2irq >= 1) && (l2irq <= 3)) {
  367. type = mpc52xx_irqx_gettype(l2irq);
  368. good_irqchip = &mpc52xx_extirq_irqchip;
  369. } else {
  370. good_irqchip = &mpc52xx_main_irqchip;
  371. }
  372. break;
  373. case MPC52xx_IRQ_L1_PERP:
  374. pr_debug("%s: Peripherals. l2=%x\n", __func__, l2irq);
  375. good_irqchip = &mpc52xx_periph_irqchip;
  376. break;
  377. case MPC52xx_IRQ_L1_SDMA:
  378. pr_debug("%s: SDMA. l2=%x\n", __func__, l2irq);
  379. good_irqchip = &mpc52xx_sdma_irqchip;
  380. break;
  381. default:
  382. pr_err("%s: invalid virq requested (0x%x)\n", __func__, virq);
  383. return -EINVAL;
  384. }
  385. switch (type) {
  386. case IRQ_TYPE_EDGE_FALLING:
  387. case IRQ_TYPE_EDGE_RISING:
  388. good_handle = handle_edge_irq;
  389. break;
  390. default:
  391. good_handle = handle_level_irq;
  392. }
  393. set_irq_chip_and_handler(virq, good_irqchip, good_handle);
  394. pr_debug("%s: virq=%x, hw=%x. type=%x\n", __func__, virq,
  395. (int)irq, type);
  396. return 0;
  397. }
  398. static struct irq_host_ops mpc52xx_irqhost_ops = {
  399. .xlate = mpc52xx_irqhost_xlate,
  400. .map = mpc52xx_irqhost_map,
  401. };
  402. /**
  403. * mpc52xx_init_irq - Initialize and register with the virq subsystem
  404. *
  405. * Hook for setting up IRQs on an mpc5200 system. A pointer to this function
  406. * is to be put into the machine definition structure.
  407. *
  408. * This function searches the device tree for an MPC5200 interrupt controller,
  409. * initializes it, and registers it with the virq subsystem.
  410. */
  411. void __init mpc52xx_init_irq(void)
  412. {
  413. u32 intr_ctrl;
  414. struct device_node *picnode;
  415. struct device_node *np;
  416. /* Remap the necessary zones */
  417. picnode = of_find_matching_node(NULL, mpc52xx_pic_ids);
  418. intr = of_iomap(picnode, 0);
  419. if (!intr)
  420. panic(__FILE__ ": find_and_map failed on 'mpc5200-pic'. "
  421. "Check node !");
  422. np = of_find_matching_node(NULL, mpc52xx_sdma_ids);
  423. sdma = of_iomap(np, 0);
  424. of_node_put(np);
  425. if (!sdma)
  426. panic(__FILE__ ": find_and_map failed on 'mpc5200-bestcomm'. "
  427. "Check node !");
  428. /* Disable all interrupt sources. */
  429. out_be32(&sdma->IntPend, 0xffffffff); /* 1 means clear pending */
  430. out_be32(&sdma->IntMask, 0xffffffff); /* 1 means disabled */
  431. out_be32(&intr->per_mask, 0x7ffffc00); /* 1 means disabled */
  432. out_be32(&intr->main_mask, 0x00010fff); /* 1 means disabled */
  433. intr_ctrl = in_be32(&intr->ctrl);
  434. intr_ctrl &= 0x00ff0000; /* Keeps IRQ[0-3] config */
  435. intr_ctrl |= 0x0f000000 | /* clear IRQ 0-3 */
  436. 0x00001000 | /* MEE master external enable */
  437. 0x00000000 | /* 0 means disable IRQ 0-3 */
  438. 0x00000001; /* CEb route critical normally */
  439. out_be32(&intr->ctrl, intr_ctrl);
  440. /* Zero a bunch of the priority settings. */
  441. out_be32(&intr->per_pri1, 0);
  442. out_be32(&intr->per_pri2, 0);
  443. out_be32(&intr->per_pri3, 0);
  444. out_be32(&intr->main_pri1, 0);
  445. out_be32(&intr->main_pri2, 0);
  446. /*
  447. * As last step, add an irq host to translate the real
  448. * hw irq information provided by the ofw to linux virq
  449. */
  450. mpc52xx_irqhost = irq_alloc_host(picnode, IRQ_HOST_MAP_LINEAR,
  451. MPC52xx_IRQ_HIGHTESTHWIRQ,
  452. &mpc52xx_irqhost_ops, -1);
  453. if (!mpc52xx_irqhost)
  454. panic(__FILE__ ": Cannot allocate the IRQ host\n");
  455. irq_set_default_host(mpc52xx_irqhost);
  456. pr_info("MPC52xx PIC is up and running!\n");
  457. }
  458. /**
  459. * mpc52xx_get_irq - Get pending interrupt number hook function
  460. *
  461. * Called by the interupt handler to determine what IRQ handler needs to be
  462. * executed.
  463. *
  464. * Status of pending interrupts is determined by reading the encoded status
  465. * register. The encoded status register has three fields; one for each of the
  466. * types of interrupts defined by the controller - 'critical', 'main' and
  467. * 'peripheral'. This function reads the status register and returns the IRQ
  468. * number associated with the highest priority pending interrupt. 'Critical'
  469. * interrupts have the highest priority, followed by 'main' interrupts, and
  470. * then 'peripheral'.
  471. *
  472. * The mpc5200 interrupt controller can be configured to boost the priority
  473. * of individual 'peripheral' interrupts. If this is the case then a special
  474. * value will appear in either the crit or main fields indicating a high
  475. * or medium priority peripheral irq has occurred.
  476. *
  477. * This function checks each of the 3 irq request fields and returns the
  478. * first pending interrupt that it finds.
  479. *
  480. * This function also identifies a 4th type of interrupt; 'bestcomm'. Each
  481. * bestcomm DMA task can raise the bestcomm peripheral interrupt. When this
  482. * occurs at task-specific IRQ# is decoded so that each task can have its
  483. * own IRQ handler.
  484. */
  485. unsigned int mpc52xx_get_irq(void)
  486. {
  487. u32 status;
  488. int irq = NO_IRQ_IGNORE;
  489. status = in_be32(&intr->enc_status);
  490. if (status & 0x00000400) { /* critical */
  491. irq = (status >> 8) & 0x3;
  492. if (irq == 2) /* high priority peripheral */
  493. goto peripheral;
  494. irq |= (MPC52xx_IRQ_L1_CRIT << MPC52xx_IRQ_L1_OFFSET);
  495. } else if (status & 0x00200000) { /* main */
  496. irq = (status >> 16) & 0x1f;
  497. if (irq == 4) /* low priority peripheral */
  498. goto peripheral;
  499. irq |= (MPC52xx_IRQ_L1_MAIN << MPC52xx_IRQ_L1_OFFSET);
  500. } else if (status & 0x20000000) { /* peripheral */
  501. peripheral:
  502. irq = (status >> 24) & 0x1f;
  503. if (irq == 0) { /* bestcomm */
  504. status = in_be32(&sdma->IntPend);
  505. irq = ffs(status) - 1;
  506. irq |= (MPC52xx_IRQ_L1_SDMA << MPC52xx_IRQ_L1_OFFSET);
  507. } else {
  508. irq |= (MPC52xx_IRQ_L1_PERP << MPC52xx_IRQ_L1_OFFSET);
  509. }
  510. }
  511. pr_debug("%s: irq=%x. virq=%d\n", __func__, irq,
  512. irq_linear_revmap(mpc52xx_irqhost, irq));
  513. return irq_linear_revmap(mpc52xx_irqhost, irq);
  514. }