skl-i2s.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * skl-i2s.h - i2s blob mapping
  3. *
  4. * Copyright (C) 2017 Intel Corp
  5. * Author: Subhransu S. Prusty < subhransu.s.prusty@intel.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 as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. *
  18. */
  19. #ifndef __SOUND_SOC_SKL_I2S_H
  20. #define __SOUND_SOC_SKL_I2S_H
  21. #define SKL_I2S_MAX_TIME_SLOTS 8
  22. #define SKL_MCLK_DIV_CLK_SRC_MASK GENMASK(17, 16)
  23. #define SKL_MNDSS_DIV_CLK_SRC_MASK GENMASK(21, 20)
  24. #define SKL_SHIFT(x) (ffs(x) - 1)
  25. #define SKL_MCLK_DIV_RATIO_MASK GENMASK(11, 0)
  26. #define is_legacy_blob(x) (x.signature != 0xEE)
  27. #define ext_to_legacy_blob(i2s_config_blob_ext) \
  28. ((struct skl_i2s_config_blob_legacy *) i2s_config_blob_ext)
  29. #define get_clk_src(mclk, mask) \
  30. ((mclk.mdivctrl & mask) >> SKL_SHIFT(mask))
  31. struct skl_i2s_config {
  32. u32 ssc0;
  33. u32 ssc1;
  34. u32 sscto;
  35. u32 sspsp;
  36. u32 sstsa;
  37. u32 ssrsa;
  38. u32 ssc2;
  39. u32 sspsp2;
  40. u32 ssc3;
  41. u32 ssioc;
  42. } __packed;
  43. struct skl_i2s_config_mclk {
  44. u32 mdivctrl;
  45. u32 mdivr;
  46. };
  47. struct skl_i2s_config_mclk_ext {
  48. u32 mdivctrl;
  49. u32 mdivr_count;
  50. u32 mdivr[0];
  51. } __packed;
  52. struct skl_i2s_config_blob_signature {
  53. u32 minor_ver : 8;
  54. u32 major_ver : 8;
  55. u32 resvdz : 8;
  56. u32 signature : 8;
  57. } __packed;
  58. struct skl_i2s_config_blob_header {
  59. struct skl_i2s_config_blob_signature sig;
  60. u32 size;
  61. };
  62. /**
  63. * struct skl_i2s_config_blob_legacy - Structure defines I2S Gateway
  64. * configuration legacy blob
  65. *
  66. * @gtw_attr: Gateway attribute for the I2S Gateway
  67. * @tdm_ts_group: TDM slot mapping against channels in the Gateway.
  68. * @i2s_cfg: I2S HW registers
  69. * @mclk: MCLK clock source and divider values
  70. */
  71. struct skl_i2s_config_blob_legacy {
  72. u32 gtw_attr;
  73. u32 tdm_ts_group[SKL_I2S_MAX_TIME_SLOTS];
  74. struct skl_i2s_config i2s_cfg;
  75. struct skl_i2s_config_mclk mclk;
  76. };
  77. struct skl_i2s_config_blob_ext {
  78. u32 gtw_attr;
  79. struct skl_i2s_config_blob_header hdr;
  80. u32 tdm_ts_group[SKL_I2S_MAX_TIME_SLOTS];
  81. struct skl_i2s_config i2s_cfg;
  82. struct skl_i2s_config_mclk_ext mclk;
  83. } __packed;
  84. #endif /* __SOUND_SOC_SKL_I2S_H */