skl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * skl.h - HD Audio skylake defintions.
  3. *
  4. * Copyright (C) 2015 Intel Corp
  5. * Author: Jeeja KP <jeeja.kp@intel.com>
  6. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. *
  19. */
  20. #ifndef __SOUND_SOC_SKL_H
  21. #define __SOUND_SOC_SKL_H
  22. #include <sound/hda_register.h>
  23. #include <sound/hdaudio_ext.h>
  24. #include <sound/soc.h>
  25. #include "skl-nhlt.h"
  26. #include "skl-ssp-clk.h"
  27. #define SKL_SUSPEND_DELAY 2000
  28. #define SKL_MAX_ASTATE_CFG 3
  29. #define AZX_PCIREG_PGCTL 0x44
  30. #define AZX_PGCTL_LSRMD_MASK (1 << 4)
  31. #define AZX_PCIREG_CGCTL 0x48
  32. #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6)
  33. /* D0I3C Register fields */
  34. #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */
  35. #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */
  36. struct skl_dsp_resource {
  37. u32 max_mcps;
  38. u32 max_mem;
  39. u32 mcps;
  40. u32 mem;
  41. };
  42. struct skl_debug;
  43. struct skl_astate_param {
  44. u32 kcps;
  45. u32 clk_src;
  46. };
  47. struct skl_astate_config {
  48. u32 count;
  49. struct skl_astate_param astate_table[0];
  50. };
  51. struct skl_fw_config {
  52. struct skl_astate_config *astate_cfg;
  53. };
  54. struct skl {
  55. struct hdac_ext_bus ebus;
  56. struct pci_dev *pci;
  57. unsigned int init_done:1; /* delayed init status */
  58. struct platform_device *dmic_dev;
  59. struct platform_device *i2s_dev;
  60. struct platform_device *clk_dev;
  61. struct snd_soc_platform *platform;
  62. struct snd_soc_dai_driver *dais;
  63. struct nhlt_acpi_table *nhlt; /* nhlt ptr */
  64. struct skl_sst *skl_sst; /* sst skl ctx */
  65. struct skl_dsp_resource resource;
  66. struct list_head ppl_list;
  67. struct list_head bind_list;
  68. const char *fw_name;
  69. char tplg_name[64];
  70. unsigned short pci_id;
  71. const struct firmware *tplg;
  72. int supend_active;
  73. struct work_struct probe_work;
  74. struct skl_debug *debugfs;
  75. u8 nr_modules;
  76. struct skl_module **modules;
  77. bool use_tplg_pcm;
  78. struct skl_fw_config cfg;
  79. struct snd_soc_acpi_mach *mach;
  80. };
  81. #define skl_to_ebus(s) (&(s)->ebus)
  82. #define ebus_to_skl(sbus) \
  83. container_of(sbus, struct skl, sbus)
  84. /* to pass dai dma data */
  85. struct skl_dma_params {
  86. u32 format;
  87. u8 stream_tag;
  88. };
  89. struct skl_machine_pdata {
  90. u32 dmic_num;
  91. bool use_tplg_pcm; /* use dais and dai links from topology */
  92. };
  93. struct skl_dsp_ops {
  94. int id;
  95. unsigned int num_cores;
  96. struct skl_dsp_loader_ops (*loader_ops)(void);
  97. int (*init)(struct device *dev, void __iomem *mmio_base,
  98. int irq, const char *fw_name,
  99. struct skl_dsp_loader_ops loader_ops,
  100. struct skl_sst **skl_sst);
  101. int (*init_fw)(struct device *dev, struct skl_sst *ctx);
  102. void (*cleanup)(struct device *dev, struct skl_sst *ctx);
  103. };
  104. int skl_platform_unregister(struct device *dev);
  105. int skl_platform_register(struct device *dev);
  106. struct nhlt_acpi_table *skl_nhlt_init(struct device *dev);
  107. void skl_nhlt_free(struct nhlt_acpi_table *addr);
  108. struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
  109. u8 link_type, u8 s_fmt, u8 no_ch,
  110. u32 s_rate, u8 dirn, u8 dev_type);
  111. int skl_get_dmic_geo(struct skl *skl);
  112. int skl_nhlt_update_topology_bin(struct skl *skl);
  113. int skl_init_dsp(struct skl *skl);
  114. int skl_free_dsp(struct skl *skl);
  115. int skl_suspend_late_dsp(struct skl *skl);
  116. int skl_suspend_dsp(struct skl *skl);
  117. int skl_resume_dsp(struct skl *skl);
  118. void skl_cleanup_resources(struct skl *skl);
  119. const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id);
  120. void skl_update_d0i3c(struct device *dev, bool enable);
  121. int skl_nhlt_create_sysfs(struct skl *skl);
  122. void skl_nhlt_remove_sysfs(struct skl *skl);
  123. void skl_get_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks);
  124. struct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id);
  125. struct skl_module_cfg;
  126. #ifdef CONFIG_DEBUG_FS
  127. struct skl_debug *skl_debugfs_init(struct skl *skl);
  128. void skl_debug_init_module(struct skl_debug *d,
  129. struct snd_soc_dapm_widget *w,
  130. struct skl_module_cfg *mconfig);
  131. #else
  132. static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
  133. {
  134. return NULL;
  135. }
  136. static inline void skl_debug_init_module(struct skl_debug *d,
  137. struct snd_soc_dapm_widget *w,
  138. struct skl_module_cfg *mconfig)
  139. {}
  140. #endif
  141. #endif /* __SOUND_SOC_SKL_H */