skl.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * skl.h - HD Audio skylake definitions.
  4. *
  5. * Copyright (C) 2015 Intel Corp
  6. * Author: Jeeja KP <[email protected]>
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. */
  11. #ifndef __SOUND_SOC_SKL_H
  12. #define __SOUND_SOC_SKL_H
  13. #include <sound/hda_register.h>
  14. #include <sound/hdaudio_ext.h>
  15. #include <sound/hda_codec.h>
  16. #include <sound/soc.h>
  17. #include "skl-ssp-clk.h"
  18. #include "skl-sst-ipc.h"
  19. #define SKL_SUSPEND_DELAY 2000
  20. #define SKL_MAX_ASTATE_CFG 3
  21. #define AZX_PCIREG_PGCTL 0x44
  22. #define AZX_PGCTL_LSRMD_MASK (1 << 4)
  23. #define AZX_PGCTL_ADSPPGD BIT(2)
  24. #define AZX_PCIREG_CGCTL 0x48
  25. #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6)
  26. #define AZX_CGCTL_ADSPDCGE BIT(1)
  27. /* D0I3C Register fields */
  28. #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */
  29. #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */
  30. #define SKL_MAX_DMACTRL_CFG 18
  31. #define DMA_CLK_CONTROLS 1
  32. #define DMA_TRANSMITION_START 2
  33. #define DMA_TRANSMITION_STOP 3
  34. #define AZX_VS_EM2_DUM BIT(23)
  35. #define AZX_REG_VS_EM2_L1SEN BIT(13)
  36. struct skl_debug;
  37. struct skl_astate_param {
  38. u32 kcps;
  39. u32 clk_src;
  40. };
  41. struct skl_astate_config {
  42. u32 count;
  43. struct skl_astate_param astate_table[];
  44. };
  45. struct skl_fw_config {
  46. struct skl_astate_config *astate_cfg;
  47. };
  48. struct skl_dev {
  49. struct hda_bus hbus;
  50. struct pci_dev *pci;
  51. unsigned int init_done:1; /* delayed init status */
  52. struct platform_device *dmic_dev;
  53. struct platform_device *i2s_dev;
  54. struct platform_device *clk_dev;
  55. struct snd_soc_component *component;
  56. struct snd_soc_dai_driver *dais;
  57. struct nhlt_acpi_table *nhlt; /* nhlt ptr */
  58. struct list_head ppl_list;
  59. struct list_head bind_list;
  60. const char *fw_name;
  61. char tplg_name[64];
  62. unsigned short pci_id;
  63. int supend_active;
  64. struct work_struct probe_work;
  65. struct skl_debug *debugfs;
  66. u8 nr_modules;
  67. struct skl_module **modules;
  68. bool use_tplg_pcm;
  69. struct skl_fw_config cfg;
  70. struct snd_soc_acpi_mach *mach;
  71. struct device *dev;
  72. struct sst_dsp *dsp;
  73. /* boot */
  74. wait_queue_head_t boot_wait;
  75. bool boot_complete;
  76. /* module load */
  77. wait_queue_head_t mod_load_wait;
  78. bool mod_load_complete;
  79. bool mod_load_status;
  80. /* IPC messaging */
  81. struct sst_generic_ipc ipc;
  82. /* callback for miscbdge */
  83. void (*enable_miscbdcge)(struct device *dev, bool enable);
  84. /* Is CGCTL.MISCBDCGE disabled */
  85. bool miscbdcg_disabled;
  86. /* Populate module information */
  87. struct list_head uuid_list;
  88. /* Is firmware loaded */
  89. bool fw_loaded;
  90. /* first boot ? */
  91. bool is_first_boot;
  92. /* multi-core */
  93. struct skl_dsp_cores cores;
  94. /* library info */
  95. struct skl_lib_info lib_info[SKL_MAX_LIB];
  96. int lib_count;
  97. /* Callback to update D0i3C register */
  98. void (*update_d0i3c)(struct device *dev, bool enable);
  99. struct skl_d0i3_data d0i3;
  100. const struct skl_dsp_ops *dsp_ops;
  101. /* Callback to update dynamic clock and power gating registers */
  102. void (*clock_power_gating)(struct device *dev, bool enable);
  103. };
  104. #define skl_to_bus(s) (&(s)->hbus.core)
  105. #define bus_to_skl(bus) container_of(bus, struct skl_dev, hbus.core)
  106. #define skl_to_hbus(s) (&(s)->hbus)
  107. #define hbus_to_skl(hbus) container_of((hbus), struct skl_dev, (hbus))
  108. /* to pass dai dma data */
  109. struct skl_dma_params {
  110. u32 format;
  111. u8 stream_tag;
  112. };
  113. struct skl_machine_pdata {
  114. bool use_tplg_pcm; /* use dais and dai links from topology */
  115. };
  116. struct skl_dsp_ops {
  117. int id;
  118. unsigned int num_cores;
  119. struct skl_dsp_loader_ops (*loader_ops)(void);
  120. int (*init)(struct device *dev, void __iomem *mmio_base,
  121. int irq, const char *fw_name,
  122. struct skl_dsp_loader_ops loader_ops,
  123. struct skl_dev **skl_sst);
  124. int (*init_fw)(struct device *dev, struct skl_dev *skl);
  125. void (*cleanup)(struct device *dev, struct skl_dev *skl);
  126. };
  127. int skl_platform_unregister(struct device *dev);
  128. int skl_platform_register(struct device *dev);
  129. int skl_nhlt_update_topology_bin(struct skl_dev *skl);
  130. int skl_init_dsp(struct skl_dev *skl);
  131. int skl_free_dsp(struct skl_dev *skl);
  132. int skl_suspend_late_dsp(struct skl_dev *skl);
  133. int skl_suspend_dsp(struct skl_dev *skl);
  134. int skl_resume_dsp(struct skl_dev *skl);
  135. void skl_cleanup_resources(struct skl_dev *skl);
  136. const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id);
  137. void skl_update_d0i3c(struct device *dev, bool enable);
  138. int skl_nhlt_create_sysfs(struct skl_dev *skl);
  139. void skl_nhlt_remove_sysfs(struct skl_dev *skl);
  140. void skl_get_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks);
  141. struct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id);
  142. int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps,
  143. u32 caps_size, u32 node_id);
  144. struct skl_module_cfg;
  145. #ifdef CONFIG_DEBUG_FS
  146. struct skl_debug *skl_debugfs_init(struct skl_dev *skl);
  147. void skl_debugfs_exit(struct skl_dev *skl);
  148. void skl_debug_init_module(struct skl_debug *d,
  149. struct snd_soc_dapm_widget *w,
  150. struct skl_module_cfg *mconfig);
  151. #else
  152. static inline struct skl_debug *skl_debugfs_init(struct skl_dev *skl)
  153. {
  154. return NULL;
  155. }
  156. static inline void skl_debugfs_exit(struct skl_dev *skl)
  157. {}
  158. static inline void skl_debug_init_module(struct skl_debug *d,
  159. struct snd_soc_dapm_widget *w,
  160. struct skl_module_cfg *mconfig)
  161. {}
  162. #endif
  163. #endif /* __SOUND_SOC_SKL_H */