mxs-saif.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
  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 as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef _MXS_SAIF_H
  19. #define _MXS_SAIF_H
  20. #define SAIF_CTRL 0x0
  21. #define SAIF_STAT 0x10
  22. #define SAIF_DATA 0x20
  23. #define SAIF_VERSION 0X30
  24. /* SAIF_CTRL */
  25. #define BM_SAIF_CTRL_SFTRST 0x80000000
  26. #define BM_SAIF_CTRL_CLKGATE 0x40000000
  27. #define BP_SAIF_CTRL_BITCLK_MULT_RATE 27
  28. #define BM_SAIF_CTRL_BITCLK_MULT_RATE 0x38000000
  29. #define BF_SAIF_CTRL_BITCLK_MULT_RATE(v) \
  30. (((v) << 27) & BM_SAIF_CTRL_BITCLK_MULT_RATE)
  31. #define BM_SAIF_CTRL_BITCLK_BASE_RATE 0x04000000
  32. #define BM_SAIF_CTRL_FIFO_ERROR_IRQ_EN 0x02000000
  33. #define BM_SAIF_CTRL_FIFO_SERVICE_IRQ_EN 0x01000000
  34. #define BP_SAIF_CTRL_RSRVD2 21
  35. #define BM_SAIF_CTRL_RSRVD2 0x00E00000
  36. #define BP_SAIF_CTRL_DMAWAIT_COUNT 16
  37. #define BM_SAIF_CTRL_DMAWAIT_COUNT 0x001F0000
  38. #define BF_SAIF_CTRL_DMAWAIT_COUNT(v) \
  39. (((v) << 16) & BM_SAIF_CTRL_DMAWAIT_COUNT)
  40. #define BP_SAIF_CTRL_CHANNEL_NUM_SELECT 14
  41. #define BM_SAIF_CTRL_CHANNEL_NUM_SELECT 0x0000C000
  42. #define BF_SAIF_CTRL_CHANNEL_NUM_SELECT(v) \
  43. (((v) << 14) & BM_SAIF_CTRL_CHANNEL_NUM_SELECT)
  44. #define BM_SAIF_CTRL_LRCLK_PULSE 0x00002000
  45. #define BM_SAIF_CTRL_BIT_ORDER 0x00001000
  46. #define BM_SAIF_CTRL_DELAY 0x00000800
  47. #define BM_SAIF_CTRL_JUSTIFY 0x00000400
  48. #define BM_SAIF_CTRL_LRCLK_POLARITY 0x00000200
  49. #define BM_SAIF_CTRL_BITCLK_EDGE 0x00000100
  50. #define BP_SAIF_CTRL_WORD_LENGTH 4
  51. #define BM_SAIF_CTRL_WORD_LENGTH 0x000000F0
  52. #define BF_SAIF_CTRL_WORD_LENGTH(v) \
  53. (((v) << 4) & BM_SAIF_CTRL_WORD_LENGTH)
  54. #define BM_SAIF_CTRL_BITCLK_48XFS_ENABLE 0x00000008
  55. #define BM_SAIF_CTRL_SLAVE_MODE 0x00000004
  56. #define BM_SAIF_CTRL_READ_MODE 0x00000002
  57. #define BM_SAIF_CTRL_RUN 0x00000001
  58. /* SAIF_STAT */
  59. #define BM_SAIF_STAT_PRESENT 0x80000000
  60. #define BP_SAIF_STAT_RSRVD2 17
  61. #define BM_SAIF_STAT_RSRVD2 0x7FFE0000
  62. #define BF_SAIF_STAT_RSRVD2(v) \
  63. (((v) << 17) & BM_SAIF_STAT_RSRVD2)
  64. #define BM_SAIF_STAT_DMA_PREQ 0x00010000
  65. #define BP_SAIF_STAT_RSRVD1 7
  66. #define BM_SAIF_STAT_RSRVD1 0x0000FF80
  67. #define BF_SAIF_STAT_RSRVD1(v) \
  68. (((v) << 7) & BM_SAIF_STAT_RSRVD1)
  69. #define BM_SAIF_STAT_FIFO_UNDERFLOW_IRQ 0x00000040
  70. #define BM_SAIF_STAT_FIFO_OVERFLOW_IRQ 0x00000020
  71. #define BM_SAIF_STAT_FIFO_SERVICE_IRQ 0x00000010
  72. #define BP_SAIF_STAT_RSRVD0 1
  73. #define BM_SAIF_STAT_RSRVD0 0x0000000E
  74. #define BF_SAIF_STAT_RSRVD0(v) \
  75. (((v) << 1) & BM_SAIF_STAT_RSRVD0)
  76. #define BM_SAIF_STAT_BUSY 0x00000001
  77. /* SAFI_DATA */
  78. #define BP_SAIF_DATA_PCM_RIGHT 16
  79. #define BM_SAIF_DATA_PCM_RIGHT 0xFFFF0000
  80. #define BF_SAIF_DATA_PCM_RIGHT(v) \
  81. (((v) << 16) & BM_SAIF_DATA_PCM_RIGHT)
  82. #define BP_SAIF_DATA_PCM_LEFT 0
  83. #define BM_SAIF_DATA_PCM_LEFT 0x0000FFFF
  84. #define BF_SAIF_DATA_PCM_LEFT(v) \
  85. (((v) << 0) & BM_SAIF_DATA_PCM_LEFT)
  86. /* SAIF_VERSION */
  87. #define BP_SAIF_VERSION_MAJOR 24
  88. #define BM_SAIF_VERSION_MAJOR 0xFF000000
  89. #define BF_SAIF_VERSION_MAJOR(v) \
  90. (((v) << 24) & BM_SAIF_VERSION_MAJOR)
  91. #define BP_SAIF_VERSION_MINOR 16
  92. #define BM_SAIF_VERSION_MINOR 0x00FF0000
  93. #define BF_SAIF_VERSION_MINOR(v) \
  94. (((v) << 16) & BM_SAIF_VERSION_MINOR)
  95. #define BP_SAIF_VERSION_STEP 0
  96. #define BM_SAIF_VERSION_STEP 0x0000FFFF
  97. #define BF_SAIF_VERSION_STEP(v) \
  98. (((v) << 0) & BM_SAIF_VERSION_STEP)
  99. #define MXS_SAIF_MCLK 0
  100. #include "mxs-pcm.h"
  101. struct mxs_saif {
  102. struct device *dev;
  103. struct clk *clk;
  104. unsigned int mclk;
  105. unsigned int mclk_in_use;
  106. void __iomem *base;
  107. unsigned int id;
  108. unsigned int master_id;
  109. unsigned int cur_rate;
  110. unsigned int ongoing;
  111. u32 fifo_underrun;
  112. u32 fifo_overrun;
  113. enum {
  114. MXS_SAIF_STATE_STOPPED,
  115. MXS_SAIF_STATE_RUNNING,
  116. } state;
  117. };
  118. extern int mxs_saif_put_mclk(unsigned int saif_id);
  119. extern int mxs_saif_get_mclk(unsigned int saif_id, unsigned int mclk,
  120. unsigned int rate);
  121. #endif