irq.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _ARCH_IRQ_H_
  7. #define _ARCH_IRQ_H_
  8. #include <dt-bindings/interrupt-router/intel-irq.h>
  9. /**
  10. * Intel interrupt router configuration mechanism
  11. *
  12. * There are two known ways of Intel interrupt router configuration mechanism
  13. * so far. On most cases, the IRQ routing configuraiton is controlled by PCI
  14. * configuraiton registers on the legacy bridge, normally PCI BDF(0, 31, 0).
  15. * On some newer platforms like BayTrail and Braswell, the IRQ routing is now
  16. * in the IBASE register block where IBASE is memory-mapped.
  17. */
  18. enum pirq_config {
  19. PIRQ_VIA_PCI,
  20. PIRQ_VIA_IBASE
  21. };
  22. /**
  23. * Intel interrupt router control block
  24. *
  25. * Its members' value will be filled in based on device tree's input.
  26. *
  27. * @config: PIRQ_VIA_PCI or PIRQ_VIA_IBASE
  28. * @link_base: link value base number
  29. * @irq_mask: IRQ mask reprenting the 16 IRQs in 8259, bit N is 1 means
  30. * IRQ N is available to be routed
  31. * @lb_bdf: irq router's PCI bus/device/function number encoding
  32. * @ibase: IBASE register block base address
  33. */
  34. struct irq_router {
  35. int config;
  36. u32 link_base;
  37. u16 irq_mask;
  38. u32 bdf;
  39. u32 ibase;
  40. };
  41. struct pirq_routing {
  42. int bdf;
  43. int pin;
  44. int pirq;
  45. };
  46. /* PIRQ link number and value conversion */
  47. #define LINK_V2N(link, base) (link - base)
  48. #define LINK_N2V(link, base) (link + base)
  49. #define PIRQ_BITMAP 0xdef8
  50. /**
  51. * cpu_irq_init() - Initialize CPU IRQ routing
  52. *
  53. * This initializes some platform-specific registers related to IRQ routing,
  54. * like configuring internal PCI devices to use which PCI interrupt pin,
  55. * and which PCI interrupt pin is mapped to which PIRQ line. Note on some
  56. * platforms, such IRQ routing might be hard-coded thus cannot configure.
  57. */
  58. void cpu_irq_init(void);
  59. /**
  60. * irq_router_common_init() - Perform common x86 interrupt init
  61. *
  62. * This creates the PIRQ routing table and routes the IRQs
  63. */
  64. int irq_router_common_init(struct udevice *dev);
  65. #endif /* _ARCH_IRQ_H_ */