sbi.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * sbi.h: SBI (Sbus Interface on sun4d) definitions
  3. *
  4. * Copyright (C) 1997 Jakub Jelinek <[email protected]>
  5. */
  6. #ifndef _SPARC_SBI_H
  7. #define _SPARC_SBI_H
  8. #include <asm/obio.h>
  9. /* SBI */
  10. struct sbi_regs {
  11. /* 0x0000 */ u32 cid; /* Component ID */
  12. /* 0x0004 */ u32 ctl; /* Control */
  13. /* 0x0008 */ u32 status; /* Status */
  14. u32 _unused1;
  15. /* 0x0010 */ u32 cfg0; /* Slot0 config reg */
  16. /* 0x0014 */ u32 cfg1; /* Slot1 config reg */
  17. /* 0x0018 */ u32 cfg2; /* Slot2 config reg */
  18. /* 0x001c */ u32 cfg3; /* Slot3 config reg */
  19. /* 0x0020 */ u32 stb0; /* Streaming buf control for slot 0 */
  20. /* 0x0024 */ u32 stb1; /* Streaming buf control for slot 1 */
  21. /* 0x0028 */ u32 stb2; /* Streaming buf control for slot 2 */
  22. /* 0x002c */ u32 stb3; /* Streaming buf control for slot 3 */
  23. /* 0x0030 */ u32 intr_state; /* Interrupt state */
  24. /* 0x0034 */ u32 intr_tid; /* Interrupt target ID */
  25. /* 0x0038 */ u32 intr_diag; /* Interrupt diagnostics */
  26. };
  27. #define SBI_CID 0x02800000
  28. #define SBI_CTL 0x02800004
  29. #define SBI_STATUS 0x02800008
  30. #define SBI_CFG0 0x02800010
  31. #define SBI_CFG1 0x02800014
  32. #define SBI_CFG2 0x02800018
  33. #define SBI_CFG3 0x0280001c
  34. #define SBI_STB0 0x02800020
  35. #define SBI_STB1 0x02800024
  36. #define SBI_STB2 0x02800028
  37. #define SBI_STB3 0x0280002c
  38. #define SBI_INTR_STATE 0x02800030
  39. #define SBI_INTR_TID 0x02800034
  40. #define SBI_INTR_DIAG 0x02800038
  41. /* Burst bits for 8, 16, 32, 64 are in cfgX registers at bits 2, 3, 4, 5 respectively */
  42. #define SBI_CFG_BURST_MASK 0x0000001e
  43. /* How to make devid from sbi no */
  44. #define SBI2DEVID(sbino) ((sbino<<4)|2)
  45. /* intr_state has 4 bits for slots 0 .. 3 and these bits are repeated for each sbus irq level
  46. *
  47. * +-------+-------+-------+-------+-------+-------+-------+-------+
  48. * SBUS IRQ LEVEL | 7 | 6 | 5 | 4 | 3 | 2 | 1 | |
  49. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Reser |
  50. * SLOT # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0| ved |
  51. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------+
  52. * Bits 31 27 23 19 15 11 7 3 0
  53. */
  54. #ifndef __ASSEMBLY__
  55. static inline int acquire_sbi(int devid, int mask)
  56. {
  57. __asm__ __volatile__ ("swapa [%2] %3, %0" :
  58. "=r" (mask) :
  59. "0" (mask),
  60. "r" (ECSR_DEV_BASE(devid) | SBI_INTR_STATE),
  61. "i" (ASI_M_CTL));
  62. return mask;
  63. }
  64. static inline void release_sbi(int devid, int mask)
  65. {
  66. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  67. "r" (mask),
  68. "r" (ECSR_DEV_BASE(devid) | SBI_INTR_STATE),
  69. "i" (ASI_M_CTL));
  70. }
  71. static inline void set_sbi_tid(int devid, int targetid)
  72. {
  73. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  74. "r" (targetid),
  75. "r" (ECSR_DEV_BASE(devid) | SBI_INTR_TID),
  76. "i" (ASI_M_CTL));
  77. }
  78. static inline int get_sbi_ctl(int devid, int cfgno)
  79. {
  80. int cfg;
  81. __asm__ __volatile__ ("lda [%1] %2, %0" :
  82. "=r" (cfg) :
  83. "r" ((ECSR_DEV_BASE(devid) | SBI_CFG0) + (cfgno<<2)),
  84. "i" (ASI_M_CTL));
  85. return cfg;
  86. }
  87. static inline void set_sbi_ctl(int devid, int cfgno, int cfg)
  88. {
  89. __asm__ __volatile__ ("sta %0, [%1] %2" : :
  90. "r" (cfg),
  91. "r" ((ECSR_DEV_BASE(devid) | SBI_CFG0) + (cfgno<<2)),
  92. "i" (ASI_M_CTL));
  93. }
  94. #endif /* !__ASSEMBLY__ */
  95. #endif /* !(_SPARC_SBI_H) */