cygnus-ssp.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (C) 2014-2015 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation version 2.
  7. *
  8. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  9. * kind, whether express or implied; without even the implied warranty
  10. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __CYGNUS_SSP_H__
  14. #define __CYGNUS_SSP_H__
  15. #define CYGNUS_TDM_DAI_MAX_SLOTS 16
  16. #define CYGNUS_MAX_PLAYBACK_PORTS 4
  17. #define CYGNUS_MAX_CAPTURE_PORTS 3
  18. #define CYGNUS_MAX_I2S_PORTS 3
  19. #define CYGNUS_MAX_PORTS CYGNUS_MAX_PLAYBACK_PORTS
  20. #define CYGNUS_AUIDO_MAX_NUM_CLKS 3
  21. #define CYGNUS_SSP_FRAMEBITS_DIV 1
  22. #define CYGNUS_SSPMODE_I2S 0
  23. #define CYGNUS_SSPMODE_TDM 1
  24. #define CYGNUS_SSPMODE_UNKNOWN -1
  25. #define CYGNUS_SSP_CLKSRC_PLL 0
  26. /* Max string length of our dt property names */
  27. #define PROP_LEN_MAX 40
  28. struct ringbuf_regs {
  29. unsigned rdaddr;
  30. unsigned wraddr;
  31. unsigned baseaddr;
  32. unsigned endaddr;
  33. unsigned fmark; /* freemark for play, fullmark for caputure */
  34. unsigned period_bytes;
  35. unsigned buf_size;
  36. };
  37. #define RINGBUF_REG_PLAYBACK(num) ((struct ringbuf_regs) { \
  38. .rdaddr = SRC_RBUF_ ##num## _RDADDR_OFFSET, \
  39. .wraddr = SRC_RBUF_ ##num## _WRADDR_OFFSET, \
  40. .baseaddr = SRC_RBUF_ ##num## _BASEADDR_OFFSET, \
  41. .endaddr = SRC_RBUF_ ##num## _ENDADDR_OFFSET, \
  42. .fmark = SRC_RBUF_ ##num## _FREE_MARK_OFFSET, \
  43. .period_bytes = 0, \
  44. .buf_size = 0, \
  45. })
  46. #define RINGBUF_REG_CAPTURE(num) ((struct ringbuf_regs) { \
  47. .rdaddr = DST_RBUF_ ##num## _RDADDR_OFFSET, \
  48. .wraddr = DST_RBUF_ ##num## _WRADDR_OFFSET, \
  49. .baseaddr = DST_RBUF_ ##num## _BASEADDR_OFFSET, \
  50. .endaddr = DST_RBUF_ ##num## _ENDADDR_OFFSET, \
  51. .fmark = DST_RBUF_ ##num## _FULL_MARK_OFFSET, \
  52. .period_bytes = 0, \
  53. .buf_size = 0, \
  54. })
  55. enum cygnus_audio_port_type {
  56. PORT_TDM,
  57. PORT_SPDIF,
  58. };
  59. struct cygnus_ssp_regs {
  60. u32 i2s_stream_cfg;
  61. u32 i2s_cfg;
  62. u32 i2s_cap_stream_cfg;
  63. u32 i2s_cap_cfg;
  64. u32 i2s_mclk_cfg;
  65. u32 bf_destch_ctrl;
  66. u32 bf_destch_cfg;
  67. u32 bf_sourcech_ctrl;
  68. u32 bf_sourcech_cfg;
  69. u32 bf_sourcech_grp;
  70. };
  71. struct cygnus_track_clk {
  72. bool cap_en;
  73. bool play_en;
  74. bool cap_clk_en;
  75. bool play_clk_en;
  76. };
  77. struct cygnus_aio_port {
  78. int portnum;
  79. int mode;
  80. bool is_slave;
  81. int streams_on; /* will be 0 if both capture and play are off */
  82. int fsync_width;
  83. int port_type;
  84. u32 mclk;
  85. u32 lrclk;
  86. u32 bit_per_frame;
  87. u32 pll_clk_num;
  88. struct cygnus_audio *cygaud;
  89. struct cygnus_ssp_regs regs;
  90. struct ringbuf_regs play_rb_regs;
  91. struct ringbuf_regs capture_rb_regs;
  92. struct snd_pcm_substream *play_stream;
  93. struct snd_pcm_substream *capture_stream;
  94. struct cygnus_track_clk clk_trace;
  95. };
  96. struct cygnus_audio {
  97. struct cygnus_aio_port portinfo[CYGNUS_MAX_PORTS];
  98. int irq_num;
  99. void __iomem *audio;
  100. struct device *dev;
  101. void __iomem *i2s_in;
  102. struct clk *audio_clk[CYGNUS_AUIDO_MAX_NUM_CLKS];
  103. int active_ports;
  104. unsigned long vco_rate;
  105. };
  106. extern int cygnus_ssp_get_mode(struct snd_soc_dai *cpu_dai);
  107. extern int cygnus_ssp_add_pll_tweak_controls(struct snd_soc_pcm_runtime *rtd);
  108. extern int cygnus_ssp_set_custom_fsync_width(struct snd_soc_dai *cpu_dai,
  109. int len);
  110. extern int cygnus_soc_platform_register(struct device *dev,
  111. struct cygnus_audio *cygaud);
  112. extern int cygnus_soc_platform_unregister(struct device *dev);
  113. extern int cygnus_ssp_set_custom_fsync_width(struct snd_soc_dai *cpu_dai,
  114. int len);
  115. #endif