smp.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Rajeshwar Ranga: Interrupt Distribution Unit API's
  9. */
  10. #ifndef __PLAT_ARCFPGA_SMP_H
  11. #define __PLAT_ARCFPGA_SMP_H
  12. #ifdef CONFIG_SMP
  13. #include <linux/types.h>
  14. #include <asm/arcregs.h>
  15. #define ARC_AUX_IDU_REG_CMD 0x2000
  16. #define ARC_AUX_IDU_REG_PARAM 0x2001
  17. #define ARC_AUX_XTL_REG_CMD 0x2002
  18. #define ARC_AUX_XTL_REG_PARAM 0x2003
  19. #define ARC_REG_MP_BCR 0x2021
  20. #define ARC_XTL_CMD_WRITE_PC 0x04
  21. #define ARC_XTL_CMD_CLEAR_HALT 0x02
  22. /*
  23. * Build Configuration Register which identifies the sub-components
  24. */
  25. struct bcr_mp {
  26. #ifdef CONFIG_CPU_BIG_ENDIAN
  27. unsigned int mp_arch:16, pad:5, sdu:1, idu:1, scu:1, ver:8;
  28. #else
  29. unsigned int ver:8, scu:1, idu:1, sdu:1, pad:5, mp_arch:16;
  30. #endif
  31. };
  32. /* IDU supports 256 common interrupts */
  33. #define NR_IDU_IRQS 256
  34. /*
  35. * The Aux Regs layout is same bit-by-bit in both BE/LE modes.
  36. * However when casted as a bitfield encoded "C" struct, gcc treats it as
  37. * memory, generating different code for BE/LE, requiring strcture adj (see
  38. * include/asm/arcregs.h)
  39. *
  40. * However when manually "carving" the value for a Aux, no special handling
  41. * of BE is needed because of the property discribed above
  42. */
  43. #define IDU_SET_COMMAND(irq, cmd) \
  44. do { \
  45. uint32_t __val; \
  46. __val = (((irq & 0xFF) << 8) | (cmd & 0xFF)); \
  47. write_aux_reg(ARC_AUX_IDU_REG_CMD, __val); \
  48. } while (0)
  49. #define IDU_SET_PARAM(par) write_aux_reg(ARC_AUX_IDU_REG_PARAM, par)
  50. #define IDU_GET_PARAM() read_aux_reg(ARC_AUX_IDU_REG_PARAM)
  51. /* IDU Commands */
  52. #define IDU_DISABLE 0x00
  53. #define IDU_ENABLE 0x01
  54. #define IDU_IRQ_CLEAR 0x02
  55. #define IDU_IRQ_ASSERT 0x03
  56. #define IDU_IRQ_WMODE 0x04
  57. #define IDU_IRQ_STATUS 0x05
  58. #define IDU_IRQ_ACK 0x06
  59. #define IDU_IRQ_PEND 0x07
  60. #define IDU_IRQ_RMODE 0x08
  61. #define IDU_IRQ_WBITMASK 0x09
  62. #define IDU_IRQ_RBITMASK 0x0A
  63. #define idu_enable() IDU_SET_COMMAND(0, IDU_ENABLE)
  64. #define idu_disable() IDU_SET_COMMAND(0, IDU_DISABLE)
  65. #define idu_irq_assert(irq) IDU_SET_COMMAND((irq), IDU_IRQ_ASSERT)
  66. #define idu_irq_clear(irq) IDU_SET_COMMAND((irq), IDU_IRQ_CLEAR)
  67. /* IDU Interrupt Mode - Destination Encoding */
  68. #define IDU_IRQ_MOD_DISABLE 0x00
  69. #define IDU_IRQ_MOD_ROUND_RECP 0x01
  70. #define IDU_IRQ_MOD_TCPU_FIRSTRECP 0x02
  71. #define IDU_IRQ_MOD_TCPU_ALLRECP 0x03
  72. /* IDU Interrupt Mode - Triggering Mode */
  73. #define IDU_IRQ_MODE_LEVEL_TRIG 0x00
  74. #define IDU_IRQ_MODE_PULSE_TRIG 0x01
  75. #define IDU_IRQ_MODE_PARAM(dest_mode, trig_mode) \
  76. (((trig_mode & 0x01) << 15) | (dest_mode & 0xFF))
  77. struct idu_irq_config {
  78. uint8_t irq;
  79. uint8_t dest_mode;
  80. uint8_t trig_mode;
  81. };
  82. struct idu_irq_status {
  83. uint8_t irq;
  84. bool enabled;
  85. bool status;
  86. bool ack;
  87. bool pend;
  88. uint8_t next_rr;
  89. };
  90. extern void idu_irq_set_tgtcpu(uint8_t irq, uint32_t mask);
  91. extern void idu_irq_set_mode(uint8_t irq, uint8_t dest_mode, uint8_t trig_mode);
  92. extern void iss_model_init_smp(unsigned int cpu);
  93. extern void iss_model_init_early_smp(void);
  94. #endif /* CONFIG_SMP */
  95. #endif