2
0

omap_intc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * TI OMAP interrupt controller emulation.
  3. *
  4. * Copyright (C) 2006-2008 Andrzej Zaborowski <balrog@zabor.org>
  5. * Copyright (C) 2007-2008 Nokia Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 or
  10. * (at your option) version 3 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "qemu/osdep.h"
  21. #include "hw/irq.h"
  22. #include "hw/qdev-properties.h"
  23. #include "hw/arm/omap.h"
  24. #include "hw/sysbus.h"
  25. #include "qemu/error-report.h"
  26. #include "qemu/module.h"
  27. #include "qapi/error.h"
  28. /* Interrupt Handlers */
  29. struct omap_intr_handler_bank_s {
  30. uint32_t irqs;
  31. uint32_t inputs;
  32. uint32_t mask;
  33. uint32_t fiq;
  34. uint32_t sens_edge;
  35. uint32_t swi;
  36. unsigned char priority[32];
  37. };
  38. struct OMAPIntcState {
  39. SysBusDevice parent_obj;
  40. qemu_irq *pins;
  41. qemu_irq parent_intr[2];
  42. MemoryRegion mmio;
  43. void *iclk;
  44. void *fclk;
  45. unsigned char nbanks;
  46. int level_only;
  47. uint32_t size;
  48. uint8_t revision;
  49. /* state */
  50. uint32_t new_agr[2];
  51. int sir_intr[2];
  52. int autoidle;
  53. uint32_t mask;
  54. struct omap_intr_handler_bank_s bank[3];
  55. };
  56. static void omap_inth_sir_update(OMAPIntcState *s, int is_fiq)
  57. {
  58. int i, j, sir_intr, p_intr, p;
  59. uint32_t level;
  60. sir_intr = 0;
  61. p_intr = 255;
  62. /* Find the interrupt line with the highest dynamic priority.
  63. * Note: 0 denotes the hightest priority.
  64. * If all interrupts have the same priority, the default order is IRQ_N,
  65. * IRQ_N-1,...,IRQ_0. */
  66. for (j = 0; j < s->nbanks; ++j) {
  67. level = s->bank[j].irqs & ~s->bank[j].mask &
  68. (is_fiq ? s->bank[j].fiq : ~s->bank[j].fiq);
  69. while (level != 0) {
  70. i = ctz32(level);
  71. p = s->bank[j].priority[i];
  72. if (p <= p_intr) {
  73. p_intr = p;
  74. sir_intr = 32 * j + i;
  75. }
  76. level &= level - 1;
  77. }
  78. }
  79. s->sir_intr[is_fiq] = sir_intr;
  80. }
  81. static inline void omap_inth_update(OMAPIntcState *s, int is_fiq)
  82. {
  83. int i;
  84. uint32_t has_intr = 0;
  85. for (i = 0; i < s->nbanks; ++i)
  86. has_intr |= s->bank[i].irqs & ~s->bank[i].mask &
  87. (is_fiq ? s->bank[i].fiq : ~s->bank[i].fiq);
  88. if (s->new_agr[is_fiq] & has_intr & s->mask) {
  89. s->new_agr[is_fiq] = 0;
  90. omap_inth_sir_update(s, is_fiq);
  91. qemu_set_irq(s->parent_intr[is_fiq], 1);
  92. }
  93. }
  94. #define INT_FALLING_EDGE 0
  95. #define INT_LOW_LEVEL 1
  96. static void omap_set_intr(void *opaque, int irq, int req)
  97. {
  98. OMAPIntcState *ih = opaque;
  99. uint32_t rise;
  100. struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
  101. int n = irq & 31;
  102. if (req) {
  103. rise = ~bank->irqs & (1 << n);
  104. if (~bank->sens_edge & (1 << n))
  105. rise &= ~bank->inputs;
  106. bank->inputs |= (1 << n);
  107. if (rise) {
  108. bank->irqs |= rise;
  109. omap_inth_update(ih, 0);
  110. omap_inth_update(ih, 1);
  111. }
  112. } else {
  113. rise = bank->sens_edge & bank->irqs & (1 << n);
  114. bank->irqs &= ~rise;
  115. bank->inputs &= ~(1 << n);
  116. }
  117. }
  118. /* Simplified version with no edge detection */
  119. static void omap_set_intr_noedge(void *opaque, int irq, int req)
  120. {
  121. OMAPIntcState *ih = opaque;
  122. uint32_t rise;
  123. struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
  124. int n = irq & 31;
  125. if (req) {
  126. rise = ~bank->inputs & (1 << n);
  127. if (rise) {
  128. bank->irqs |= bank->inputs |= rise;
  129. omap_inth_update(ih, 0);
  130. omap_inth_update(ih, 1);
  131. }
  132. } else
  133. bank->irqs = (bank->inputs &= ~(1 << n)) | bank->swi;
  134. }
  135. static uint64_t omap_inth_read(void *opaque, hwaddr addr,
  136. unsigned size)
  137. {
  138. OMAPIntcState *s = opaque;
  139. int i, offset = addr;
  140. int bank_no = offset >> 8;
  141. int line_no;
  142. struct omap_intr_handler_bank_s *bank = &s->bank[bank_no];
  143. offset &= 0xff;
  144. switch (offset) {
  145. case 0x00: /* ITR */
  146. return bank->irqs;
  147. case 0x04: /* MIR */
  148. return bank->mask;
  149. case 0x10: /* SIR_IRQ_CODE */
  150. case 0x14: /* SIR_FIQ_CODE */
  151. if (bank_no != 0)
  152. break;
  153. line_no = s->sir_intr[(offset - 0x10) >> 2];
  154. bank = &s->bank[line_no >> 5];
  155. i = line_no & 31;
  156. if (((bank->sens_edge >> i) & 1) == INT_FALLING_EDGE)
  157. bank->irqs &= ~(1 << i);
  158. return line_no;
  159. case 0x18: /* CONTROL_REG */
  160. if (bank_no != 0)
  161. break;
  162. return 0;
  163. case 0x1c: /* ILR0 */
  164. case 0x20: /* ILR1 */
  165. case 0x24: /* ILR2 */
  166. case 0x28: /* ILR3 */
  167. case 0x2c: /* ILR4 */
  168. case 0x30: /* ILR5 */
  169. case 0x34: /* ILR6 */
  170. case 0x38: /* ILR7 */
  171. case 0x3c: /* ILR8 */
  172. case 0x40: /* ILR9 */
  173. case 0x44: /* ILR10 */
  174. case 0x48: /* ILR11 */
  175. case 0x4c: /* ILR12 */
  176. case 0x50: /* ILR13 */
  177. case 0x54: /* ILR14 */
  178. case 0x58: /* ILR15 */
  179. case 0x5c: /* ILR16 */
  180. case 0x60: /* ILR17 */
  181. case 0x64: /* ILR18 */
  182. case 0x68: /* ILR19 */
  183. case 0x6c: /* ILR20 */
  184. case 0x70: /* ILR21 */
  185. case 0x74: /* ILR22 */
  186. case 0x78: /* ILR23 */
  187. case 0x7c: /* ILR24 */
  188. case 0x80: /* ILR25 */
  189. case 0x84: /* ILR26 */
  190. case 0x88: /* ILR27 */
  191. case 0x8c: /* ILR28 */
  192. case 0x90: /* ILR29 */
  193. case 0x94: /* ILR30 */
  194. case 0x98: /* ILR31 */
  195. i = (offset - 0x1c) >> 2;
  196. return (bank->priority[i] << 2) |
  197. (((bank->sens_edge >> i) & 1) << 1) |
  198. ((bank->fiq >> i) & 1);
  199. case 0x9c: /* ISR */
  200. return 0x00000000;
  201. }
  202. OMAP_BAD_REG(addr);
  203. return 0;
  204. }
  205. static void omap_inth_write(void *opaque, hwaddr addr,
  206. uint64_t value, unsigned size)
  207. {
  208. OMAPIntcState *s = opaque;
  209. int i, offset = addr;
  210. int bank_no = offset >> 8;
  211. struct omap_intr_handler_bank_s *bank = &s->bank[bank_no];
  212. offset &= 0xff;
  213. switch (offset) {
  214. case 0x00: /* ITR */
  215. /* Important: ignore the clearing if the IRQ is level-triggered and
  216. the input bit is 1 */
  217. bank->irqs &= value | (bank->inputs & bank->sens_edge);
  218. return;
  219. case 0x04: /* MIR */
  220. bank->mask = value;
  221. omap_inth_update(s, 0);
  222. omap_inth_update(s, 1);
  223. return;
  224. case 0x10: /* SIR_IRQ_CODE */
  225. case 0x14: /* SIR_FIQ_CODE */
  226. OMAP_RO_REG(addr);
  227. break;
  228. case 0x18: /* CONTROL_REG */
  229. if (bank_no != 0)
  230. break;
  231. if (value & 2) {
  232. qemu_set_irq(s->parent_intr[1], 0);
  233. s->new_agr[1] = ~0;
  234. omap_inth_update(s, 1);
  235. }
  236. if (value & 1) {
  237. qemu_set_irq(s->parent_intr[0], 0);
  238. s->new_agr[0] = ~0;
  239. omap_inth_update(s, 0);
  240. }
  241. return;
  242. case 0x1c: /* ILR0 */
  243. case 0x20: /* ILR1 */
  244. case 0x24: /* ILR2 */
  245. case 0x28: /* ILR3 */
  246. case 0x2c: /* ILR4 */
  247. case 0x30: /* ILR5 */
  248. case 0x34: /* ILR6 */
  249. case 0x38: /* ILR7 */
  250. case 0x3c: /* ILR8 */
  251. case 0x40: /* ILR9 */
  252. case 0x44: /* ILR10 */
  253. case 0x48: /* ILR11 */
  254. case 0x4c: /* ILR12 */
  255. case 0x50: /* ILR13 */
  256. case 0x54: /* ILR14 */
  257. case 0x58: /* ILR15 */
  258. case 0x5c: /* ILR16 */
  259. case 0x60: /* ILR17 */
  260. case 0x64: /* ILR18 */
  261. case 0x68: /* ILR19 */
  262. case 0x6c: /* ILR20 */
  263. case 0x70: /* ILR21 */
  264. case 0x74: /* ILR22 */
  265. case 0x78: /* ILR23 */
  266. case 0x7c: /* ILR24 */
  267. case 0x80: /* ILR25 */
  268. case 0x84: /* ILR26 */
  269. case 0x88: /* ILR27 */
  270. case 0x8c: /* ILR28 */
  271. case 0x90: /* ILR29 */
  272. case 0x94: /* ILR30 */
  273. case 0x98: /* ILR31 */
  274. i = (offset - 0x1c) >> 2;
  275. bank->priority[i] = (value >> 2) & 0x1f;
  276. bank->sens_edge &= ~(1 << i);
  277. bank->sens_edge |= ((value >> 1) & 1) << i;
  278. bank->fiq &= ~(1 << i);
  279. bank->fiq |= (value & 1) << i;
  280. return;
  281. case 0x9c: /* ISR */
  282. for (i = 0; i < 32; i ++)
  283. if (value & (1 << i)) {
  284. omap_set_intr(s, 32 * bank_no + i, 1);
  285. return;
  286. }
  287. return;
  288. }
  289. OMAP_BAD_REG(addr);
  290. }
  291. static const MemoryRegionOps omap_inth_mem_ops = {
  292. .read = omap_inth_read,
  293. .write = omap_inth_write,
  294. .endianness = DEVICE_NATIVE_ENDIAN,
  295. .valid = {
  296. .min_access_size = 4,
  297. .max_access_size = 4,
  298. },
  299. };
  300. static void omap_inth_reset(DeviceState *dev)
  301. {
  302. OMAPIntcState *s = OMAP_INTC(dev);
  303. int i;
  304. for (i = 0; i < s->nbanks; ++i){
  305. s->bank[i].irqs = 0x00000000;
  306. s->bank[i].mask = 0xffffffff;
  307. s->bank[i].sens_edge = 0x00000000;
  308. s->bank[i].fiq = 0x00000000;
  309. s->bank[i].inputs = 0x00000000;
  310. s->bank[i].swi = 0x00000000;
  311. memset(s->bank[i].priority, 0, sizeof(s->bank[i].priority));
  312. if (s->level_only)
  313. s->bank[i].sens_edge = 0xffffffff;
  314. }
  315. s->new_agr[0] = ~0;
  316. s->new_agr[1] = ~0;
  317. s->sir_intr[0] = 0;
  318. s->sir_intr[1] = 0;
  319. s->autoidle = 0;
  320. s->mask = ~0;
  321. qemu_set_irq(s->parent_intr[0], 0);
  322. qemu_set_irq(s->parent_intr[1], 0);
  323. }
  324. static void omap_intc_init(Object *obj)
  325. {
  326. DeviceState *dev = DEVICE(obj);
  327. OMAPIntcState *s = OMAP_INTC(obj);
  328. SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
  329. s->nbanks = 1;
  330. sysbus_init_irq(sbd, &s->parent_intr[0]);
  331. sysbus_init_irq(sbd, &s->parent_intr[1]);
  332. qdev_init_gpio_in(dev, omap_set_intr, s->nbanks * 32);
  333. memory_region_init_io(&s->mmio, obj, &omap_inth_mem_ops, s,
  334. "omap-intc", s->size);
  335. sysbus_init_mmio(sbd, &s->mmio);
  336. }
  337. static void omap_intc_realize(DeviceState *dev, Error **errp)
  338. {
  339. OMAPIntcState *s = OMAP_INTC(dev);
  340. if (!s->iclk) {
  341. error_setg(errp, "omap-intc: clk not connected");
  342. }
  343. }
  344. void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk)
  345. {
  346. intc->iclk = clk;
  347. }
  348. void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk)
  349. {
  350. intc->fclk = clk;
  351. }
  352. static Property omap_intc_properties[] = {
  353. DEFINE_PROP_UINT32("size", OMAPIntcState, size, 0x100),
  354. DEFINE_PROP_END_OF_LIST(),
  355. };
  356. static void omap_intc_class_init(ObjectClass *klass, void *data)
  357. {
  358. DeviceClass *dc = DEVICE_CLASS(klass);
  359. dc->reset = omap_inth_reset;
  360. device_class_set_props(dc, omap_intc_properties);
  361. /* Reason: pointer property "clk" */
  362. dc->user_creatable = false;
  363. dc->realize = omap_intc_realize;
  364. }
  365. static const TypeInfo omap_intc_info = {
  366. .name = "omap-intc",
  367. .parent = TYPE_OMAP_INTC,
  368. .instance_init = omap_intc_init,
  369. .class_init = omap_intc_class_init,
  370. };
  371. static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
  372. unsigned size)
  373. {
  374. OMAPIntcState *s = opaque;
  375. int offset = addr;
  376. int bank_no, line_no;
  377. struct omap_intr_handler_bank_s *bank = NULL;
  378. if ((offset & 0xf80) == 0x80) {
  379. bank_no = (offset & 0x60) >> 5;
  380. if (bank_no < s->nbanks) {
  381. offset &= ~0x60;
  382. bank = &s->bank[bank_no];
  383. } else {
  384. OMAP_BAD_REG(addr);
  385. return 0;
  386. }
  387. }
  388. switch (offset) {
  389. case 0x00: /* INTC_REVISION */
  390. return s->revision;
  391. case 0x10: /* INTC_SYSCONFIG */
  392. return (s->autoidle >> 2) & 1;
  393. case 0x14: /* INTC_SYSSTATUS */
  394. return 1; /* RESETDONE */
  395. case 0x40: /* INTC_SIR_IRQ */
  396. return s->sir_intr[0];
  397. case 0x44: /* INTC_SIR_FIQ */
  398. return s->sir_intr[1];
  399. case 0x48: /* INTC_CONTROL */
  400. return (!s->mask) << 2; /* GLOBALMASK */
  401. case 0x4c: /* INTC_PROTECTION */
  402. return 0;
  403. case 0x50: /* INTC_IDLE */
  404. return s->autoidle & 3;
  405. /* Per-bank registers */
  406. case 0x80: /* INTC_ITR */
  407. return bank->inputs;
  408. case 0x84: /* INTC_MIR */
  409. return bank->mask;
  410. case 0x88: /* INTC_MIR_CLEAR */
  411. case 0x8c: /* INTC_MIR_SET */
  412. return 0;
  413. case 0x90: /* INTC_ISR_SET */
  414. return bank->swi;
  415. case 0x94: /* INTC_ISR_CLEAR */
  416. return 0;
  417. case 0x98: /* INTC_PENDING_IRQ */
  418. return bank->irqs & ~bank->mask & ~bank->fiq;
  419. case 0x9c: /* INTC_PENDING_FIQ */
  420. return bank->irqs & ~bank->mask & bank->fiq;
  421. /* Per-line registers */
  422. case 0x100 ... 0x300: /* INTC_ILR */
  423. bank_no = (offset - 0x100) >> 7;
  424. if (bank_no > s->nbanks)
  425. break;
  426. bank = &s->bank[bank_no];
  427. line_no = (offset & 0x7f) >> 2;
  428. return (bank->priority[line_no] << 2) |
  429. ((bank->fiq >> line_no) & 1);
  430. }
  431. OMAP_BAD_REG(addr);
  432. return 0;
  433. }
  434. static void omap2_inth_write(void *opaque, hwaddr addr,
  435. uint64_t value, unsigned size)
  436. {
  437. OMAPIntcState *s = opaque;
  438. int offset = addr;
  439. int bank_no, line_no;
  440. struct omap_intr_handler_bank_s *bank = NULL;
  441. if ((offset & 0xf80) == 0x80) {
  442. bank_no = (offset & 0x60) >> 5;
  443. if (bank_no < s->nbanks) {
  444. offset &= ~0x60;
  445. bank = &s->bank[bank_no];
  446. } else {
  447. OMAP_BAD_REG(addr);
  448. return;
  449. }
  450. }
  451. switch (offset) {
  452. case 0x10: /* INTC_SYSCONFIG */
  453. s->autoidle &= 4;
  454. s->autoidle |= (value & 1) << 2;
  455. if (value & 2) { /* SOFTRESET */
  456. omap_inth_reset(DEVICE(s));
  457. }
  458. return;
  459. case 0x48: /* INTC_CONTROL */
  460. s->mask = (value & 4) ? 0 : ~0; /* GLOBALMASK */
  461. if (value & 2) { /* NEWFIQAGR */
  462. qemu_set_irq(s->parent_intr[1], 0);
  463. s->new_agr[1] = ~0;
  464. omap_inth_update(s, 1);
  465. }
  466. if (value & 1) { /* NEWIRQAGR */
  467. qemu_set_irq(s->parent_intr[0], 0);
  468. s->new_agr[0] = ~0;
  469. omap_inth_update(s, 0);
  470. }
  471. return;
  472. case 0x4c: /* INTC_PROTECTION */
  473. /* TODO: Make a bitmap (or sizeof(char)map) of access privileges
  474. * for every register, see Chapter 3 and 4 for privileged mode. */
  475. if (value & 1)
  476. fprintf(stderr, "%s: protection mode enable attempt\n",
  477. __func__);
  478. return;
  479. case 0x50: /* INTC_IDLE */
  480. s->autoidle &= ~3;
  481. s->autoidle |= value & 3;
  482. return;
  483. /* Per-bank registers */
  484. case 0x84: /* INTC_MIR */
  485. bank->mask = value;
  486. omap_inth_update(s, 0);
  487. omap_inth_update(s, 1);
  488. return;
  489. case 0x88: /* INTC_MIR_CLEAR */
  490. bank->mask &= ~value;
  491. omap_inth_update(s, 0);
  492. omap_inth_update(s, 1);
  493. return;
  494. case 0x8c: /* INTC_MIR_SET */
  495. bank->mask |= value;
  496. return;
  497. case 0x90: /* INTC_ISR_SET */
  498. bank->irqs |= bank->swi |= value;
  499. omap_inth_update(s, 0);
  500. omap_inth_update(s, 1);
  501. return;
  502. case 0x94: /* INTC_ISR_CLEAR */
  503. bank->swi &= ~value;
  504. bank->irqs = bank->swi & bank->inputs;
  505. return;
  506. /* Per-line registers */
  507. case 0x100 ... 0x300: /* INTC_ILR */
  508. bank_no = (offset - 0x100) >> 7;
  509. if (bank_no > s->nbanks)
  510. break;
  511. bank = &s->bank[bank_no];
  512. line_no = (offset & 0x7f) >> 2;
  513. bank->priority[line_no] = (value >> 2) & 0x3f;
  514. bank->fiq &= ~(1 << line_no);
  515. bank->fiq |= (value & 1) << line_no;
  516. return;
  517. case 0x00: /* INTC_REVISION */
  518. case 0x14: /* INTC_SYSSTATUS */
  519. case 0x40: /* INTC_SIR_IRQ */
  520. case 0x44: /* INTC_SIR_FIQ */
  521. case 0x80: /* INTC_ITR */
  522. case 0x98: /* INTC_PENDING_IRQ */
  523. case 0x9c: /* INTC_PENDING_FIQ */
  524. OMAP_RO_REG(addr);
  525. return;
  526. }
  527. OMAP_BAD_REG(addr);
  528. }
  529. static const MemoryRegionOps omap2_inth_mem_ops = {
  530. .read = omap2_inth_read,
  531. .write = omap2_inth_write,
  532. .endianness = DEVICE_NATIVE_ENDIAN,
  533. .valid = {
  534. .min_access_size = 4,
  535. .max_access_size = 4,
  536. },
  537. };
  538. static void omap2_intc_init(Object *obj)
  539. {
  540. DeviceState *dev = DEVICE(obj);
  541. OMAPIntcState *s = OMAP_INTC(obj);
  542. SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
  543. s->level_only = 1;
  544. s->nbanks = 3;
  545. sysbus_init_irq(sbd, &s->parent_intr[0]);
  546. sysbus_init_irq(sbd, &s->parent_intr[1]);
  547. qdev_init_gpio_in(dev, omap_set_intr_noedge, s->nbanks * 32);
  548. memory_region_init_io(&s->mmio, obj, &omap2_inth_mem_ops, s,
  549. "omap2-intc", 0x1000);
  550. sysbus_init_mmio(sbd, &s->mmio);
  551. }
  552. static void omap2_intc_realize(DeviceState *dev, Error **errp)
  553. {
  554. OMAPIntcState *s = OMAP_INTC(dev);
  555. if (!s->iclk) {
  556. error_setg(errp, "omap2-intc: iclk not connected");
  557. return;
  558. }
  559. if (!s->fclk) {
  560. error_setg(errp, "omap2-intc: fclk not connected");
  561. return;
  562. }
  563. }
  564. static Property omap2_intc_properties[] = {
  565. DEFINE_PROP_UINT8("revision", OMAPIntcState,
  566. revision, 0x21),
  567. DEFINE_PROP_END_OF_LIST(),
  568. };
  569. static void omap2_intc_class_init(ObjectClass *klass, void *data)
  570. {
  571. DeviceClass *dc = DEVICE_CLASS(klass);
  572. dc->reset = omap_inth_reset;
  573. device_class_set_props(dc, omap2_intc_properties);
  574. /* Reason: pointer property "iclk", "fclk" */
  575. dc->user_creatable = false;
  576. dc->realize = omap2_intc_realize;
  577. }
  578. static const TypeInfo omap2_intc_info = {
  579. .name = "omap2-intc",
  580. .parent = TYPE_OMAP_INTC,
  581. .instance_init = omap2_intc_init,
  582. .class_init = omap2_intc_class_init,
  583. };
  584. static const TypeInfo omap_intc_type_info = {
  585. .name = TYPE_OMAP_INTC,
  586. .parent = TYPE_SYS_BUS_DEVICE,
  587. .instance_size = sizeof(OMAPIntcState),
  588. .abstract = true,
  589. };
  590. static void omap_intc_register_types(void)
  591. {
  592. type_register_static(&omap_intc_type_info);
  593. type_register_static(&omap_intc_info);
  594. type_register_static(&omap2_intc_info);
  595. }
  596. type_init(omap_intc_register_types)