hda_register.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * HD-audio controller (Azalia) registers and helpers
  3. *
  4. * For traditional reasons, we still use azx_ prefix here
  5. */
  6. #ifndef __SOUND_HDA_REGISTER_H
  7. #define __SOUND_HDA_REGISTER_H
  8. #include <linux/io.h>
  9. #include <sound/hdaudio.h>
  10. #define AZX_REG_GCAP 0x00
  11. #define AZX_GCAP_64OK (1 << 0) /* 64bit address support */
  12. #define AZX_GCAP_NSDO (3 << 1) /* # of serial data out signals */
  13. #define AZX_GCAP_BSS (31 << 3) /* # of bidirectional streams */
  14. #define AZX_GCAP_ISS (15 << 8) /* # of input streams */
  15. #define AZX_GCAP_OSS (15 << 12) /* # of output streams */
  16. #define AZX_REG_VMIN 0x02
  17. #define AZX_REG_VMAJ 0x03
  18. #define AZX_REG_OUTPAY 0x04
  19. #define AZX_REG_INPAY 0x06
  20. #define AZX_REG_GCTL 0x08
  21. #define AZX_GCTL_RESET (1 << 0) /* controller reset */
  22. #define AZX_GCTL_FCNTRL (1 << 1) /* flush control */
  23. #define AZX_GCTL_UNSOL (1 << 8) /* accept unsol. response enable */
  24. #define AZX_REG_WAKEEN 0x0c
  25. #define AZX_REG_STATESTS 0x0e
  26. #define AZX_REG_GSTS 0x10
  27. #define AZX_GSTS_FSTS (1 << 1) /* flush status */
  28. #define AZX_REG_INTCTL 0x20
  29. #define AZX_REG_INTSTS 0x24
  30. #define AZX_REG_WALLCLK 0x30 /* 24Mhz source */
  31. #define AZX_REG_OLD_SSYNC 0x34 /* SSYNC for old ICH */
  32. #define AZX_REG_SSYNC 0x38
  33. #define AZX_REG_CORBLBASE 0x40
  34. #define AZX_REG_CORBUBASE 0x44
  35. #define AZX_REG_CORBWP 0x48
  36. #define AZX_REG_CORBRP 0x4a
  37. #define AZX_CORBRP_RST (1 << 15) /* read pointer reset */
  38. #define AZX_REG_CORBCTL 0x4c
  39. #define AZX_CORBCTL_RUN (1 << 1) /* enable DMA */
  40. #define AZX_CORBCTL_CMEIE (1 << 0) /* enable memory error irq */
  41. #define AZX_REG_CORBSTS 0x4d
  42. #define AZX_CORBSTS_CMEI (1 << 0) /* memory error indication */
  43. #define AZX_REG_CORBSIZE 0x4e
  44. #define AZX_REG_RIRBLBASE 0x50
  45. #define AZX_REG_RIRBUBASE 0x54
  46. #define AZX_REG_RIRBWP 0x58
  47. #define AZX_RIRBWP_RST (1 << 15) /* write pointer reset */
  48. #define AZX_REG_RINTCNT 0x5a
  49. #define AZX_REG_RIRBCTL 0x5c
  50. #define AZX_RBCTL_IRQ_EN (1 << 0) /* enable IRQ */
  51. #define AZX_RBCTL_DMA_EN (1 << 1) /* enable DMA */
  52. #define AZX_RBCTL_OVERRUN_EN (1 << 2) /* enable overrun irq */
  53. #define AZX_REG_RIRBSTS 0x5d
  54. #define AZX_RBSTS_IRQ (1 << 0) /* response irq */
  55. #define AZX_RBSTS_OVERRUN (1 << 2) /* overrun irq */
  56. #define AZX_REG_RIRBSIZE 0x5e
  57. #define AZX_REG_IC 0x60
  58. #define AZX_REG_IR 0x64
  59. #define AZX_REG_IRS 0x68
  60. #define AZX_IRS_VALID (1<<1)
  61. #define AZX_IRS_BUSY (1<<0)
  62. #define AZX_REG_DPLBASE 0x70
  63. #define AZX_REG_DPUBASE 0x74
  64. #define AZX_DPLBASE_ENABLE 0x1 /* Enable position buffer */
  65. /* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
  66. enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
  67. /* stream register offsets from stream base */
  68. #define AZX_REG_SD_CTL 0x00
  69. #define AZX_REG_SD_STS 0x03
  70. #define AZX_REG_SD_LPIB 0x04
  71. #define AZX_REG_SD_CBL 0x08
  72. #define AZX_REG_SD_LVI 0x0c
  73. #define AZX_REG_SD_FIFOW 0x0e
  74. #define AZX_REG_SD_FIFOSIZE 0x10
  75. #define AZX_REG_SD_FORMAT 0x12
  76. #define AZX_REG_SD_BDLPL 0x18
  77. #define AZX_REG_SD_BDLPU 0x1c
  78. /* PCI space */
  79. #define AZX_PCIREG_TCSEL 0x44
  80. /*
  81. * other constants
  82. */
  83. /* max number of fragments - we may use more if allocating more pages for BDL */
  84. #define BDL_SIZE 4096
  85. #define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16)
  86. #define AZX_MAX_FRAG 32
  87. /* max buffer size - no h/w limit, you can increase as you like */
  88. #define AZX_MAX_BUF_SIZE (1024*1024*1024)
  89. /* RIRB int mask: overrun[2], response[0] */
  90. #define RIRB_INT_RESPONSE 0x01
  91. #define RIRB_INT_OVERRUN 0x04
  92. #define RIRB_INT_MASK 0x05
  93. /* STATESTS int mask: S3,SD2,SD1,SD0 */
  94. #define STATESTS_INT_MASK ((1 << HDA_MAX_CODECS) - 1)
  95. /* SD_CTL bits */
  96. #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
  97. #define SD_CTL_DMA_START 0x02 /* stream DMA start bit */
  98. #define SD_CTL_STRIPE (3 << 16) /* stripe control */
  99. #define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */
  100. #define SD_CTL_DIR (1 << 19) /* bi-directional stream */
  101. #define SD_CTL_STREAM_TAG_MASK (0xf << 20)
  102. #define SD_CTL_STREAM_TAG_SHIFT 20
  103. /* SD_CTL and SD_STS */
  104. #define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */
  105. #define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */
  106. #define SD_INT_COMPLETE 0x04 /* completion interrupt */
  107. #define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
  108. SD_INT_COMPLETE)
  109. /* SD_STS */
  110. #define SD_STS_FIFO_READY 0x20 /* FIFO ready */
  111. /* INTCTL and INTSTS */
  112. #define AZX_INT_ALL_STREAM 0xff /* all stream interrupts */
  113. #define AZX_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
  114. #define AZX_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
  115. /* below are so far hardcoded - should read registers in future */
  116. #define AZX_MAX_CORB_ENTRIES 256
  117. #define AZX_MAX_RIRB_ENTRIES 256
  118. /*
  119. * helpers to read the stream position
  120. */
  121. static inline unsigned int
  122. snd_hdac_stream_get_pos_lpib(struct hdac_stream *stream)
  123. {
  124. return snd_hdac_stream_readl(stream, SD_LPIB);
  125. }
  126. static inline unsigned int
  127. snd_hdac_stream_get_pos_posbuf(struct hdac_stream *stream)
  128. {
  129. return le32_to_cpu(*stream->posbuf);
  130. }
  131. #endif /* __SOUND_HDA_REGISTER_H */