mt2701-afe-common.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * mt2701-afe-common.h -- Mediatek 2701 audio driver definitions
  3. *
  4. * Copyright (c) 2016 MediaTek Inc.
  5. * Author: Garlic Tseng <garlic.tseng@mediatek.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 and
  9. * only version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #ifndef _MT_2701_AFE_COMMON_H_
  17. #define _MT_2701_AFE_COMMON_H_
  18. #include <sound/soc.h>
  19. #include <linux/clk.h>
  20. #include <linux/regmap.h>
  21. #include "mt2701-reg.h"
  22. #include "../common/mtk-base-afe.h"
  23. #define MT2701_STREAM_DIR_NUM (SNDRV_PCM_STREAM_LAST + 1)
  24. #define MT2701_PLL_DOMAIN_0_RATE 98304000
  25. #define MT2701_PLL_DOMAIN_1_RATE 90316800
  26. #define MT2701_I2S_NUM 4
  27. enum {
  28. MT2701_MEMIF_DL1,
  29. MT2701_MEMIF_DL2,
  30. MT2701_MEMIF_DL3,
  31. MT2701_MEMIF_DL4,
  32. MT2701_MEMIF_DL5,
  33. MT2701_MEMIF_DL_SINGLE_NUM,
  34. MT2701_MEMIF_DLM = MT2701_MEMIF_DL_SINGLE_NUM,
  35. MT2701_MEMIF_UL1,
  36. MT2701_MEMIF_UL2,
  37. MT2701_MEMIF_UL3,
  38. MT2701_MEMIF_UL4,
  39. MT2701_MEMIF_UL5,
  40. MT2701_MEMIF_DLBT,
  41. MT2701_MEMIF_ULBT,
  42. MT2701_MEMIF_NUM,
  43. MT2701_IO_I2S = MT2701_MEMIF_NUM,
  44. MT2701_IO_2ND_I2S,
  45. MT2701_IO_3RD_I2S,
  46. MT2701_IO_4TH_I2S,
  47. MT2701_IO_5TH_I2S,
  48. MT2701_IO_6TH_I2S,
  49. MT2701_IO_MRG,
  50. };
  51. enum {
  52. MT2701_IRQ_ASYS_IRQ1,
  53. MT2701_IRQ_ASYS_IRQ2,
  54. MT2701_IRQ_ASYS_IRQ3,
  55. MT2701_IRQ_ASYS_END,
  56. };
  57. enum audio_base_clock {
  58. MT2701_INFRA_SYS_AUDIO,
  59. MT2701_TOP_AUD_MCLK_SRC0,
  60. MT2701_TOP_AUD_MCLK_SRC1,
  61. MT2701_TOP_AUD_A1SYS,
  62. MT2701_TOP_AUD_A2SYS,
  63. MT2701_AUDSYS_AFE,
  64. MT2701_AUDSYS_AFE_CONN,
  65. MT2701_AUDSYS_A1SYS,
  66. MT2701_AUDSYS_A2SYS,
  67. MT2701_BASE_CLK_NUM,
  68. };
  69. static const unsigned int mt2701_afe_backup_list[] = {
  70. AUDIO_TOP_CON0,
  71. AUDIO_TOP_CON4,
  72. AUDIO_TOP_CON5,
  73. ASYS_TOP_CON,
  74. AFE_CONN0,
  75. AFE_CONN1,
  76. AFE_CONN2,
  77. AFE_CONN3,
  78. AFE_CONN15,
  79. AFE_CONN16,
  80. AFE_CONN17,
  81. AFE_CONN18,
  82. AFE_CONN19,
  83. AFE_CONN20,
  84. AFE_CONN21,
  85. AFE_CONN22,
  86. AFE_DAC_CON0,
  87. AFE_MEMIF_PBUF_SIZE,
  88. };
  89. struct mt2701_i2s_data {
  90. int i2s_ctrl_reg;
  91. int i2s_asrc_fs_shift;
  92. int i2s_asrc_fs_mask;
  93. };
  94. enum mt2701_i2s_dir {
  95. I2S_OUT,
  96. I2S_IN,
  97. I2S_DIR_NUM,
  98. };
  99. struct mt2701_i2s_path {
  100. int dai_id;
  101. int mclk_rate;
  102. int on[I2S_DIR_NUM];
  103. int occupied[I2S_DIR_NUM];
  104. const struct mt2701_i2s_data *i2s_data[I2S_DIR_NUM];
  105. struct clk *hop_ck[I2S_DIR_NUM];
  106. struct clk *sel_ck;
  107. struct clk *div_ck;
  108. struct clk *mclk_ck;
  109. struct clk *asrco_ck;
  110. };
  111. struct mt2701_afe_private {
  112. struct mt2701_i2s_path i2s_path[MT2701_I2S_NUM];
  113. struct clk *base_ck[MT2701_BASE_CLK_NUM];
  114. struct clk *mrgif_ck;
  115. bool mrg_enable[MT2701_STREAM_DIR_NUM];
  116. };
  117. #endif