skl.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_PGCTL_ADSPPGD BIT(2)
  32. #define AZX_PCIREG_CGCTL 0x48
  33. #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6)
  34. #define AZX_CGCTL_ADSPDCGE BIT(1)
  35. /* D0I3C Register fields */
  36. #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */
  37. #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */
  38. #define SKL_MAX_DMACTRL_CFG 18
  39. #define DMA_CLK_CONTROLS 1
  40. #define DMA_TRANSMITION_START 2
  41. #define DMA_TRANSMITION_STOP 3
  42. #define AZX_REG_VS_EM2_L1SEN BIT(13)
  43. struct skl_dsp_resource {
  44. u32 max_mcps;
  45. u32 max_mem;
  46. u32 mcps;
  47. u32 mem;
  48. };
  49. struct skl_debug;
  50. struct skl_astate_param {
  51. u32 kcps;
  52. u32 clk_src;
  53. };
  54. struct skl_astate_config {
  55. u32 count;
  56. struct skl_astate_param astate_table[0];
  57. };
  58. struct skl_fw_config {
  59. struct skl_astate_config *astate_cfg;
  60. };
  61. struct skl {
  62. struct hdac_bus hbus;
  63. struct pci_dev *pci;
  64. unsigned int init_done:1; /* delayed init status */
  65. struct platform_device *dmic_dev;
  66. struct platform_device *i2s_dev;
  67. struct platform_device *clk_dev;
  68. struct snd_soc_component *component;
  69. struct snd_soc_dai_driver *dais;
  70. struct nhlt_acpi_table *nhlt; /* nhlt ptr */
  71. struct skl_sst *skl_sst; /* sst skl ctx */
  72. struct skl_dsp_resource resource;
  73. struct list_head ppl_list;
  74. struct list_head bind_list;
  75. const char *fw_name;
  76. char tplg_name[64];
  77. unsigned short pci_id;
  78. const struct firmware *tplg;
  79. int supend_active;
  80. struct work_struct probe_work;
  81. struct skl_debug *debugfs;
  82. u8 nr_modules;
  83. struct skl_module **modules;
  84. bool use_tplg_pcm;
  85. struct skl_fw_config cfg;
  86. struct snd_soc_acpi_mach *mach;
  87. };
  88. #define skl_to_bus(s) (&(s)->hbus)
  89. #define bus_to_skl(bus) container_of(bus, struct skl, hbus)
  90. /* to pass dai dma data */
  91. struct skl_dma_params {
  92. u32 format;
  93. u8 stream_tag;
  94. };
  95. struct skl_machine_pdata {
  96. u32 dmic_num;
  97. bool use_tplg_pcm; /* use dais and dai links from topology */
  98. };
  99. struct skl_dsp_ops {
  100. int id;
  101. unsigned int num_cores;
  102. struct skl_dsp_loader_ops (*loader_ops)(void);
  103. int (*init)(struct device *dev, void __iomem *mmio_base,
  104. int irq, const char *fw_name,
  105. struct skl_dsp_loader_ops loader_ops,
  106. struct skl_sst **skl_sst);
  107. int (*init_fw)(struct device *dev, struct skl_sst *ctx);
  108. void (*cleanup)(struct device *dev, struct skl_sst *ctx);
  109. };
  110. int skl_platform_unregister(struct device *dev);
  111. int skl_platform_register(struct device *dev);
  112. struct nhlt_acpi_table *skl_nhlt_init(struct device *dev);
  113. void skl_nhlt_free(struct nhlt_acpi_table *addr);
  114. struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
  115. u8 link_type, u8 s_fmt, u8 no_ch,
  116. u32 s_rate, u8 dirn, u8 dev_type);
  117. int skl_get_dmic_geo(struct skl *skl);
  118. int skl_nhlt_update_topology_bin(struct skl *skl);
  119. int skl_init_dsp(struct skl *skl);
  120. int skl_free_dsp(struct skl *skl);
  121. int skl_suspend_late_dsp(struct skl *skl);
  122. int skl_suspend_dsp(struct skl *skl);
  123. int skl_resume_dsp(struct skl *skl);
  124. void skl_cleanup_resources(struct skl *skl);
  125. const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id);
  126. void skl_update_d0i3c(struct device *dev, bool enable);
  127. int skl_nhlt_create_sysfs(struct skl *skl);
  128. void skl_nhlt_remove_sysfs(struct skl *skl);
  129. void skl_get_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks);
  130. struct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id);
  131. int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps,
  132. u32 caps_size, u32 node_id);
  133. struct skl_module_cfg;
  134. #ifdef CONFIG_DEBUG_FS
  135. struct skl_debug *skl_debugfs_init(struct skl *skl);
  136. void skl_debug_init_module(struct skl_debug *d,
  137. struct snd_soc_dapm_widget *w,
  138. struct skl_module_cfg *mconfig);
  139. #else
  140. static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
  141. {
  142. return NULL;
  143. }
  144. static inline void skl_debug_init_module(struct skl_debug *d,
  145. struct snd_soc_dapm_widget *w,
  146. struct skl_module_cfg *mconfig)
  147. {}
  148. #endif
  149. #endif /* __SOUND_SOC_SKL_H */