irq.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. /*
  2. * S3C24XX IRQ handling
  3. *
  4. * Copyright (c) 2003-2004 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * Copyright (c) 2012 Heiko Stuebner <heiko@sntech.de>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/slab.h>
  20. #include <linux/module.h>
  21. #include <linux/io.h>
  22. #include <linux/err.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/ioport.h>
  25. #include <linux/device.h>
  26. #include <linux/irqdomain.h>
  27. #include <asm/mach/irq.h>
  28. #include <mach/regs-irq.h>
  29. #include <mach/regs-gpio.h>
  30. #include <plat/cpu.h>
  31. #include <plat/regs-irqtype.h>
  32. #include <plat/pm.h>
  33. #include <plat/irq.h>
  34. #define S3C_IRQTYPE_NONE 0
  35. #define S3C_IRQTYPE_EINT 1
  36. #define S3C_IRQTYPE_EDGE 2
  37. #define S3C_IRQTYPE_LEVEL 3
  38. struct s3c_irq_data {
  39. unsigned int type;
  40. unsigned long parent_irq;
  41. /* data gets filled during init */
  42. struct s3c_irq_intc *intc;
  43. unsigned long sub_bits;
  44. struct s3c_irq_intc *sub_intc;
  45. };
  46. /*
  47. * Sructure holding the controller data
  48. * @reg_pending register holding pending irqs
  49. * @reg_intpnd special register intpnd in main intc
  50. * @reg_mask mask register
  51. * @domain irq_domain of the controller
  52. * @parent parent controller for ext and sub irqs
  53. * @irqs irq-data, always s3c_irq_data[32]
  54. */
  55. struct s3c_irq_intc {
  56. void __iomem *reg_pending;
  57. void __iomem *reg_intpnd;
  58. void __iomem *reg_mask;
  59. struct irq_domain *domain;
  60. struct s3c_irq_intc *parent;
  61. struct s3c_irq_data *irqs;
  62. };
  63. static void s3c_irq_mask(struct irq_data *data)
  64. {
  65. struct s3c_irq_intc *intc = data->domain->host_data;
  66. struct s3c_irq_intc *parent_intc = intc->parent;
  67. struct s3c_irq_data *irq_data = &intc->irqs[data->hwirq];
  68. struct s3c_irq_data *parent_data;
  69. unsigned long mask;
  70. unsigned int irqno;
  71. mask = __raw_readl(intc->reg_mask);
  72. mask |= (1UL << data->hwirq);
  73. __raw_writel(mask, intc->reg_mask);
  74. if (parent_intc && irq_data->parent_irq) {
  75. parent_data = &parent_intc->irqs[irq_data->parent_irq];
  76. /* check to see if we need to mask the parent IRQ */
  77. if ((mask & parent_data->sub_bits) == parent_data->sub_bits) {
  78. irqno = irq_find_mapping(parent_intc->domain,
  79. irq_data->parent_irq);
  80. s3c_irq_mask(irq_get_irq_data(irqno));
  81. }
  82. }
  83. }
  84. static void s3c_irq_unmask(struct irq_data *data)
  85. {
  86. struct s3c_irq_intc *intc = data->domain->host_data;
  87. struct s3c_irq_intc *parent_intc = intc->parent;
  88. struct s3c_irq_data *irq_data = &intc->irqs[data->hwirq];
  89. unsigned long mask;
  90. unsigned int irqno;
  91. mask = __raw_readl(intc->reg_mask);
  92. mask &= ~(1UL << data->hwirq);
  93. __raw_writel(mask, intc->reg_mask);
  94. if (parent_intc && irq_data->parent_irq) {
  95. irqno = irq_find_mapping(parent_intc->domain,
  96. irq_data->parent_irq);
  97. s3c_irq_unmask(irq_get_irq_data(irqno));
  98. }
  99. }
  100. static inline void s3c_irq_ack(struct irq_data *data)
  101. {
  102. struct s3c_irq_intc *intc = data->domain->host_data;
  103. unsigned long bitval = 1UL << data->hwirq;
  104. __raw_writel(bitval, intc->reg_pending);
  105. if (intc->reg_intpnd)
  106. __raw_writel(bitval, intc->reg_intpnd);
  107. }
  108. static int s3c_irqext_type_set(void __iomem *gpcon_reg,
  109. void __iomem *extint_reg,
  110. unsigned long gpcon_offset,
  111. unsigned long extint_offset,
  112. unsigned int type)
  113. {
  114. unsigned long newvalue = 0, value;
  115. /* Set the GPIO to external interrupt mode */
  116. value = __raw_readl(gpcon_reg);
  117. value = (value & ~(3 << gpcon_offset)) | (0x02 << gpcon_offset);
  118. __raw_writel(value, gpcon_reg);
  119. /* Set the external interrupt to pointed trigger type */
  120. switch (type)
  121. {
  122. case IRQ_TYPE_NONE:
  123. pr_warn("No edge setting!\n");
  124. break;
  125. case IRQ_TYPE_EDGE_RISING:
  126. newvalue = S3C2410_EXTINT_RISEEDGE;
  127. break;
  128. case IRQ_TYPE_EDGE_FALLING:
  129. newvalue = S3C2410_EXTINT_FALLEDGE;
  130. break;
  131. case IRQ_TYPE_EDGE_BOTH:
  132. newvalue = S3C2410_EXTINT_BOTHEDGE;
  133. break;
  134. case IRQ_TYPE_LEVEL_LOW:
  135. newvalue = S3C2410_EXTINT_LOWLEV;
  136. break;
  137. case IRQ_TYPE_LEVEL_HIGH:
  138. newvalue = S3C2410_EXTINT_HILEV;
  139. break;
  140. default:
  141. pr_err("No such irq type %d", type);
  142. return -EINVAL;
  143. }
  144. value = __raw_readl(extint_reg);
  145. value = (value & ~(7 << extint_offset)) | (newvalue << extint_offset);
  146. __raw_writel(value, extint_reg);
  147. return 0;
  148. }
  149. /* FIXME: make static when it's out of plat-samsung/irq.h */
  150. int s3c_irqext_type(struct irq_data *data, unsigned int type)
  151. {
  152. void __iomem *extint_reg;
  153. void __iomem *gpcon_reg;
  154. unsigned long gpcon_offset, extint_offset;
  155. if ((data->hwirq >= 4) && (data->hwirq <= 7)) {
  156. gpcon_reg = S3C2410_GPFCON;
  157. extint_reg = S3C24XX_EXTINT0;
  158. gpcon_offset = (data->hwirq) * 2;
  159. extint_offset = (data->hwirq) * 4;
  160. } else if ((data->hwirq >= 8) && (data->hwirq <= 15)) {
  161. gpcon_reg = S3C2410_GPGCON;
  162. extint_reg = S3C24XX_EXTINT1;
  163. gpcon_offset = (data->hwirq - 8) * 2;
  164. extint_offset = (data->hwirq - 8) * 4;
  165. } else if ((data->hwirq >= 16) && (data->hwirq <= 23)) {
  166. gpcon_reg = S3C2410_GPGCON;
  167. extint_reg = S3C24XX_EXTINT2;
  168. gpcon_offset = (data->hwirq - 8) * 2;
  169. extint_offset = (data->hwirq - 16) * 4;
  170. } else {
  171. return -EINVAL;
  172. }
  173. return s3c_irqext_type_set(gpcon_reg, extint_reg, gpcon_offset,
  174. extint_offset, type);
  175. }
  176. static int s3c_irqext0_type(struct irq_data *data, unsigned int type)
  177. {
  178. void __iomem *extint_reg;
  179. void __iomem *gpcon_reg;
  180. unsigned long gpcon_offset, extint_offset;
  181. if ((data->hwirq >= 0) && (data->hwirq <= 3)) {
  182. gpcon_reg = S3C2410_GPFCON;
  183. extint_reg = S3C24XX_EXTINT0;
  184. gpcon_offset = (data->hwirq) * 2;
  185. extint_offset = (data->hwirq) * 4;
  186. } else {
  187. return -EINVAL;
  188. }
  189. return s3c_irqext_type_set(gpcon_reg, extint_reg, gpcon_offset,
  190. extint_offset, type);
  191. }
  192. struct irq_chip s3c_irq_chip = {
  193. .name = "s3c",
  194. .irq_ack = s3c_irq_ack,
  195. .irq_mask = s3c_irq_mask,
  196. .irq_unmask = s3c_irq_unmask,
  197. .irq_set_wake = s3c_irq_wake
  198. };
  199. struct irq_chip s3c_irq_level_chip = {
  200. .name = "s3c-level",
  201. .irq_mask = s3c_irq_mask,
  202. .irq_unmask = s3c_irq_unmask,
  203. .irq_ack = s3c_irq_ack,
  204. };
  205. static struct irq_chip s3c_irqext_chip = {
  206. .name = "s3c-ext",
  207. .irq_mask = s3c_irq_mask,
  208. .irq_unmask = s3c_irq_unmask,
  209. .irq_ack = s3c_irq_ack,
  210. .irq_set_type = s3c_irqext_type,
  211. .irq_set_wake = s3c_irqext_wake
  212. };
  213. static struct irq_chip s3c_irq_eint0t4 = {
  214. .name = "s3c-ext0",
  215. .irq_ack = s3c_irq_ack,
  216. .irq_mask = s3c_irq_mask,
  217. .irq_unmask = s3c_irq_unmask,
  218. .irq_set_wake = s3c_irq_wake,
  219. .irq_set_type = s3c_irqext0_type,
  220. };
  221. static void s3c_irq_demux(unsigned int irq, struct irq_desc *desc)
  222. {
  223. struct irq_chip *chip = irq_desc_get_chip(desc);
  224. struct s3c_irq_intc *intc = desc->irq_data.domain->host_data;
  225. struct s3c_irq_data *irq_data = &intc->irqs[desc->irq_data.hwirq];
  226. struct s3c_irq_intc *sub_intc = irq_data->sub_intc;
  227. unsigned long src;
  228. unsigned long msk;
  229. unsigned int n;
  230. chained_irq_enter(chip, desc);
  231. src = __raw_readl(sub_intc->reg_pending);
  232. msk = __raw_readl(sub_intc->reg_mask);
  233. src &= ~msk;
  234. src &= irq_data->sub_bits;
  235. while (src) {
  236. n = __ffs(src);
  237. src &= ~(1 << n);
  238. generic_handle_irq(irq_find_mapping(sub_intc->domain, n));
  239. }
  240. chained_irq_exit(chip, desc);
  241. }
  242. #ifdef CONFIG_FIQ
  243. /**
  244. * s3c24xx_set_fiq - set the FIQ routing
  245. * @irq: IRQ number to route to FIQ on processor.
  246. * @on: Whether to route @irq to the FIQ, or to remove the FIQ routing.
  247. *
  248. * Change the state of the IRQ to FIQ routing depending on @irq and @on. If
  249. * @on is true, the @irq is checked to see if it can be routed and the
  250. * interrupt controller updated to route the IRQ. If @on is false, the FIQ
  251. * routing is cleared, regardless of which @irq is specified.
  252. */
  253. int s3c24xx_set_fiq(unsigned int irq, bool on)
  254. {
  255. u32 intmod;
  256. unsigned offs;
  257. if (on) {
  258. offs = irq - FIQ_START;
  259. if (offs > 31)
  260. return -EINVAL;
  261. intmod = 1 << offs;
  262. } else {
  263. intmod = 0;
  264. }
  265. __raw_writel(intmod, S3C2410_INTMOD);
  266. return 0;
  267. }
  268. EXPORT_SYMBOL_GPL(s3c24xx_set_fiq);
  269. #endif
  270. static int s3c24xx_irq_map(struct irq_domain *h, unsigned int virq,
  271. irq_hw_number_t hw)
  272. {
  273. struct s3c_irq_intc *intc = h->host_data;
  274. struct s3c_irq_data *irq_data = &intc->irqs[hw];
  275. struct s3c_irq_intc *parent_intc;
  276. struct s3c_irq_data *parent_irq_data;
  277. unsigned int irqno;
  278. if (!intc) {
  279. pr_err("irq-s3c24xx: no controller found for hwirq %lu\n", hw);
  280. return -EINVAL;
  281. }
  282. if (!irq_data) {
  283. pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n", hw);
  284. return -EINVAL;
  285. }
  286. /* attach controller pointer to irq_data */
  287. irq_data->intc = intc;
  288. /* set handler and flags */
  289. switch (irq_data->type) {
  290. case S3C_IRQTYPE_NONE:
  291. return 0;
  292. case S3C_IRQTYPE_EINT:
  293. if (irq_data->parent_irq)
  294. irq_set_chip_and_handler(virq, &s3c_irqext_chip,
  295. handle_edge_irq);
  296. else
  297. irq_set_chip_and_handler(virq, &s3c_irq_eint0t4,
  298. handle_edge_irq);
  299. break;
  300. case S3C_IRQTYPE_EDGE:
  301. if (irq_data->parent_irq ||
  302. intc->reg_pending == S3C2416_SRCPND2)
  303. irq_set_chip_and_handler(virq, &s3c_irq_level_chip,
  304. handle_edge_irq);
  305. else
  306. irq_set_chip_and_handler(virq, &s3c_irq_chip,
  307. handle_edge_irq);
  308. break;
  309. case S3C_IRQTYPE_LEVEL:
  310. if (irq_data->parent_irq)
  311. irq_set_chip_and_handler(virq, &s3c_irq_level_chip,
  312. handle_level_irq);
  313. else
  314. irq_set_chip_and_handler(virq, &s3c_irq_chip,
  315. handle_level_irq);
  316. break;
  317. default:
  318. pr_err("irq-s3c24xx: unsupported irqtype %d\n", irq_data->type);
  319. return -EINVAL;
  320. }
  321. set_irq_flags(virq, IRQF_VALID);
  322. if (irq_data->parent_irq) {
  323. parent_intc = intc->parent;
  324. if (!parent_intc) {
  325. pr_err("irq-s3c24xx: no parent controller found for hwirq %lu\n",
  326. hw);
  327. goto err;
  328. }
  329. parent_irq_data = &parent_intc->irqs[irq_data->parent_irq];
  330. if (!irq_data) {
  331. pr_err("irq-s3c24xx: no irq data found for hwirq %lu\n",
  332. hw);
  333. goto err;
  334. }
  335. parent_irq_data->sub_intc = intc;
  336. parent_irq_data->sub_bits |= (1UL << hw);
  337. /* attach the demuxer to the parent irq */
  338. irqno = irq_find_mapping(parent_intc->domain,
  339. irq_data->parent_irq);
  340. if (!irqno) {
  341. pr_err("irq-s3c24xx: could not find mapping for parent irq %lu\n",
  342. irq_data->parent_irq);
  343. goto err;
  344. }
  345. irq_set_chained_handler(irqno, s3c_irq_demux);
  346. }
  347. return 0;
  348. err:
  349. set_irq_flags(virq, 0);
  350. /* the only error can result from bad mapping data*/
  351. return -EINVAL;
  352. }
  353. static struct irq_domain_ops s3c24xx_irq_ops = {
  354. .map = s3c24xx_irq_map,
  355. .xlate = irq_domain_xlate_twocell,
  356. };
  357. static void s3c24xx_clear_intc(struct s3c_irq_intc *intc)
  358. {
  359. void __iomem *reg_source;
  360. unsigned long pend;
  361. unsigned long last;
  362. int i;
  363. /* if intpnd is set, read the next pending irq from there */
  364. reg_source = intc->reg_intpnd ? intc->reg_intpnd : intc->reg_pending;
  365. last = 0;
  366. for (i = 0; i < 4; i++) {
  367. pend = __raw_readl(reg_source);
  368. if (pend == 0 || pend == last)
  369. break;
  370. __raw_writel(pend, intc->reg_pending);
  371. if (intc->reg_intpnd)
  372. __raw_writel(pend, intc->reg_intpnd);
  373. pr_info("irq: clearing pending status %08x\n", (int)pend);
  374. last = pend;
  375. }
  376. }
  377. struct s3c_irq_intc *s3c24xx_init_intc(struct device_node *np,
  378. struct s3c_irq_data *irq_data,
  379. struct s3c_irq_intc *parent,
  380. unsigned long address)
  381. {
  382. struct s3c_irq_intc *intc;
  383. void __iomem *base = (void *)0xf6000000; /* static mapping */
  384. int irq_num;
  385. int irq_start;
  386. int irq_offset;
  387. int ret;
  388. intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL);
  389. if (!intc)
  390. return ERR_PTR(-ENOMEM);
  391. intc->irqs = irq_data;
  392. if (parent)
  393. intc->parent = parent;
  394. /* select the correct data for the controller.
  395. * Need to hard code the irq num start and offset
  396. * to preserve the static mapping for now
  397. */
  398. switch (address) {
  399. case 0x4a000000:
  400. pr_debug("irq: found main intc\n");
  401. intc->reg_pending = base;
  402. intc->reg_mask = base + 0x08;
  403. intc->reg_intpnd = base + 0x10;
  404. irq_num = 32;
  405. irq_start = S3C2410_IRQ(0);
  406. irq_offset = 0;
  407. break;
  408. case 0x4a000018:
  409. pr_debug("irq: found subintc\n");
  410. intc->reg_pending = base + 0x18;
  411. intc->reg_mask = base + 0x1c;
  412. irq_num = 29;
  413. irq_start = S3C2410_IRQSUB(0);
  414. irq_offset = 0;
  415. break;
  416. case 0x4a000040:
  417. pr_debug("irq: found intc2\n");
  418. intc->reg_pending = base + 0x40;
  419. intc->reg_mask = base + 0x48;
  420. intc->reg_intpnd = base + 0x50;
  421. irq_num = 8;
  422. irq_start = S3C2416_IRQ(0);
  423. irq_offset = 0;
  424. break;
  425. case 0x560000a4:
  426. pr_debug("irq: found eintc\n");
  427. base = (void *)0xfd000000;
  428. intc->reg_mask = base + 0xa4;
  429. intc->reg_pending = base + 0x08;
  430. irq_num = 20;
  431. irq_start = S3C2410_IRQ(32);
  432. irq_offset = 4;
  433. break;
  434. default:
  435. pr_err("irq: unsupported controller address\n");
  436. ret = -EINVAL;
  437. goto err;
  438. }
  439. /* now that all the data is complete, init the irq-domain */
  440. s3c24xx_clear_intc(intc);
  441. intc->domain = irq_domain_add_legacy(np, irq_num, irq_start,
  442. irq_offset, &s3c24xx_irq_ops,
  443. intc);
  444. if (!intc->domain) {
  445. pr_err("irq: could not create irq-domain\n");
  446. ret = -EINVAL;
  447. goto err;
  448. }
  449. return intc;
  450. err:
  451. kfree(intc);
  452. return ERR_PTR(ret);
  453. }
  454. /* s3c24xx_init_irq
  455. *
  456. * Initialise S3C2410 IRQ system
  457. */
  458. static struct s3c_irq_data init_base[32] = {
  459. { .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
  460. { .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
  461. { .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
  462. { .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
  463. { .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
  464. { .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
  465. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  466. { .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
  467. { .type = S3C_IRQTYPE_EDGE, }, /* TICK */
  468. { .type = S3C_IRQTYPE_EDGE, }, /* WDT */
  469. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
  470. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
  471. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
  472. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
  473. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
  474. { .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
  475. { .type = S3C_IRQTYPE_EDGE, }, /* LCD */
  476. { .type = S3C_IRQTYPE_EDGE, }, /* DMA0 */
  477. { .type = S3C_IRQTYPE_EDGE, }, /* DMA1 */
  478. { .type = S3C_IRQTYPE_EDGE, }, /* DMA2 */
  479. { .type = S3C_IRQTYPE_EDGE, }, /* DMA3 */
  480. { .type = S3C_IRQTYPE_EDGE, }, /* SDI */
  481. { .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
  482. { .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
  483. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  484. { .type = S3C_IRQTYPE_EDGE, }, /* USBD */
  485. { .type = S3C_IRQTYPE_EDGE, }, /* USBH */
  486. { .type = S3C_IRQTYPE_EDGE, }, /* IIC */
  487. { .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
  488. { .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
  489. { .type = S3C_IRQTYPE_EDGE, }, /* RTC */
  490. { .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
  491. };
  492. static struct s3c_irq_data init_eint[32] = {
  493. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  494. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  495. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  496. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  497. { .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT4 */
  498. { .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT5 */
  499. { .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT6 */
  500. { .type = S3C_IRQTYPE_EINT, .parent_irq = 4 }, /* EINT7 */
  501. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT8 */
  502. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT9 */
  503. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT10 */
  504. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT11 */
  505. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT12 */
  506. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT13 */
  507. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT14 */
  508. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT15 */
  509. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT16 */
  510. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT17 */
  511. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT18 */
  512. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT19 */
  513. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT20 */
  514. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT21 */
  515. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT22 */
  516. { .type = S3C_IRQTYPE_EINT, .parent_irq = 5 }, /* EINT23 */
  517. };
  518. static struct s3c_irq_data init_subint[32] = {
  519. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
  520. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
  521. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
  522. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
  523. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
  524. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
  525. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
  526. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
  527. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
  528. { .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
  529. { .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
  530. };
  531. void __init s3c24xx_init_irq(void)
  532. {
  533. struct s3c_irq_intc *main_intc;
  534. #ifdef CONFIG_FIQ
  535. init_FIQ(FIQ_START);
  536. #endif
  537. main_intc = s3c24xx_init_intc(NULL, &init_base[0], NULL, 0x4a000000);
  538. if (IS_ERR(main_intc)) {
  539. pr_err("irq: could not create main interrupt controller\n");
  540. return;
  541. }
  542. s3c24xx_init_intc(NULL, &init_subint[0], main_intc, 0x4a000018);
  543. s3c24xx_init_intc(NULL, &init_eint[0], main_intc, 0x560000a4);
  544. }
  545. #ifdef CONFIG_CPU_S3C2416
  546. static struct s3c_irq_data init_s3c2416base[32] = {
  547. { .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
  548. { .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
  549. { .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
  550. { .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
  551. { .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
  552. { .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
  553. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  554. { .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
  555. { .type = S3C_IRQTYPE_EDGE, }, /* TICK */
  556. { .type = S3C_IRQTYPE_LEVEL, }, /* WDT/AC97 */
  557. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
  558. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
  559. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
  560. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
  561. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
  562. { .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
  563. { .type = S3C_IRQTYPE_LEVEL, }, /* LCD */
  564. { .type = S3C_IRQTYPE_LEVEL, }, /* DMA */
  565. { .type = S3C_IRQTYPE_LEVEL, }, /* UART3 */
  566. { .type = S3C_IRQTYPE_NONE, }, /* reserved */
  567. { .type = S3C_IRQTYPE_EDGE, }, /* SDI1 */
  568. { .type = S3C_IRQTYPE_EDGE, }, /* SDI0 */
  569. { .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
  570. { .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
  571. { .type = S3C_IRQTYPE_EDGE, }, /* NAND */
  572. { .type = S3C_IRQTYPE_EDGE, }, /* USBD */
  573. { .type = S3C_IRQTYPE_EDGE, }, /* USBH */
  574. { .type = S3C_IRQTYPE_EDGE, }, /* IIC */
  575. { .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
  576. { .type = S3C_IRQTYPE_NONE, },
  577. { .type = S3C_IRQTYPE_EDGE, }, /* RTC */
  578. { .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
  579. };
  580. static struct s3c_irq_data init_s3c2416subint[32] = {
  581. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
  582. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
  583. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
  584. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
  585. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
  586. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
  587. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
  588. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
  589. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
  590. { .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
  591. { .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
  592. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  593. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  594. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  595. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  596. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD2 */
  597. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD3 */
  598. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD4 */
  599. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA0 */
  600. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA1 */
  601. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA2 */
  602. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA3 */
  603. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA4 */
  604. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA5 */
  605. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-RX */
  606. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-TX */
  607. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-ERR */
  608. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* WDT */
  609. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* AC97 */
  610. };
  611. static struct s3c_irq_data init_s3c2416_second[32] = {
  612. { .type = S3C_IRQTYPE_EDGE }, /* 2D */
  613. { .type = S3C_IRQTYPE_EDGE }, /* IIC1 */
  614. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  615. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  616. { .type = S3C_IRQTYPE_EDGE }, /* PCM0 */
  617. { .type = S3C_IRQTYPE_EDGE }, /* PCM1 */
  618. { .type = S3C_IRQTYPE_EDGE }, /* I2S0 */
  619. { .type = S3C_IRQTYPE_EDGE }, /* I2S1 */
  620. };
  621. void __init s3c2416_init_irq(void)
  622. {
  623. struct s3c_irq_intc *main_intc;
  624. pr_info("S3C2416: IRQ Support\n");
  625. #ifdef CONFIG_FIQ
  626. init_FIQ(FIQ_START);
  627. #endif
  628. main_intc = s3c24xx_init_intc(NULL, &init_s3c2416base[0], NULL, 0x4a000000);
  629. if (IS_ERR(main_intc)) {
  630. pr_err("irq: could not create main interrupt controller\n");
  631. return;
  632. }
  633. s3c24xx_init_intc(NULL, &init_eint[0], main_intc, 0x560000a4);
  634. s3c24xx_init_intc(NULL, &init_s3c2416subint[0], main_intc, 0x4a000018);
  635. s3c24xx_init_intc(NULL, &init_s3c2416_second[0], NULL, 0x4a000040);
  636. }
  637. #endif
  638. #ifdef CONFIG_CPU_S3C2443
  639. static struct s3c_irq_data init_s3c2443base[32] = {
  640. { .type = S3C_IRQTYPE_EINT, }, /* EINT0 */
  641. { .type = S3C_IRQTYPE_EINT, }, /* EINT1 */
  642. { .type = S3C_IRQTYPE_EINT, }, /* EINT2 */
  643. { .type = S3C_IRQTYPE_EINT, }, /* EINT3 */
  644. { .type = S3C_IRQTYPE_LEVEL, }, /* EINT4to7 */
  645. { .type = S3C_IRQTYPE_LEVEL, }, /* EINT8to23 */
  646. { .type = S3C_IRQTYPE_LEVEL, }, /* CAM */
  647. { .type = S3C_IRQTYPE_EDGE, }, /* nBATT_FLT */
  648. { .type = S3C_IRQTYPE_EDGE, }, /* TICK */
  649. { .type = S3C_IRQTYPE_LEVEL, }, /* WDT/AC97 */
  650. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER0 */
  651. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER1 */
  652. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER2 */
  653. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER3 */
  654. { .type = S3C_IRQTYPE_EDGE, }, /* TIMER4 */
  655. { .type = S3C_IRQTYPE_LEVEL, }, /* UART2 */
  656. { .type = S3C_IRQTYPE_LEVEL, }, /* LCD */
  657. { .type = S3C_IRQTYPE_LEVEL, }, /* DMA */
  658. { .type = S3C_IRQTYPE_LEVEL, }, /* UART3 */
  659. { .type = S3C_IRQTYPE_EDGE, }, /* CFON */
  660. { .type = S3C_IRQTYPE_EDGE, }, /* SDI1 */
  661. { .type = S3C_IRQTYPE_EDGE, }, /* SDI0 */
  662. { .type = S3C_IRQTYPE_EDGE, }, /* SPI0 */
  663. { .type = S3C_IRQTYPE_LEVEL, }, /* UART1 */
  664. { .type = S3C_IRQTYPE_EDGE, }, /* NAND */
  665. { .type = S3C_IRQTYPE_EDGE, }, /* USBD */
  666. { .type = S3C_IRQTYPE_EDGE, }, /* USBH */
  667. { .type = S3C_IRQTYPE_EDGE, }, /* IIC */
  668. { .type = S3C_IRQTYPE_LEVEL, }, /* UART0 */
  669. { .type = S3C_IRQTYPE_EDGE, }, /* SPI1 */
  670. { .type = S3C_IRQTYPE_EDGE, }, /* RTC */
  671. { .type = S3C_IRQTYPE_LEVEL, }, /* ADCPARENT */
  672. };
  673. static struct s3c_irq_data init_s3c2443subint[32] = {
  674. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-RX */
  675. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-TX */
  676. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 28 }, /* UART0-ERR */
  677. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-RX */
  678. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-TX */
  679. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 23 }, /* UART1-ERR */
  680. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-RX */
  681. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-TX */
  682. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
  683. { .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
  684. { .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
  685. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_C */
  686. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_P */
  687. { .type = S3C_IRQTYPE_NONE }, /* reserved */
  688. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD1 */
  689. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD2 */
  690. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD3 */
  691. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 16 }, /* LCD4 */
  692. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA0 */
  693. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA1 */
  694. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA2 */
  695. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA3 */
  696. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA4 */
  697. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 17 }, /* DMA5 */
  698. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-RX */
  699. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-TX */
  700. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 18 }, /* UART3-ERR */
  701. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* WDT */
  702. { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* AC97 */
  703. };
  704. void __init s3c2443_init_irq(void)
  705. {
  706. struct s3c_irq_intc *main_intc;
  707. pr_info("S3C2443: IRQ Support\n");
  708. #ifdef CONFIG_FIQ
  709. init_FIQ(FIQ_START);
  710. #endif
  711. main_intc = s3c24xx_init_intc(NULL, &init_s3c2443base[0], NULL, 0x4a000000);
  712. if (IS_ERR(main_intc)) {
  713. pr_err("irq: could not create main interrupt controller\n");
  714. return;
  715. }
  716. s3c24xx_init_intc(NULL, &init_eint[0], main_intc, 0x560000a4);
  717. s3c24xx_init_intc(NULL, &init_s3c2443subint[0], main_intc, 0x4a000018);
  718. }
  719. #endif