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 21 #ifndef __SOUND_SOC_SKL_H 22 #define __SOUND_SOC_SKL_H 23 24 #include <sound/hda_register.h> 25 #include <sound/hdaudio_ext.h> 26 #include <sound/soc.h> 27 #include "skl-nhlt.h" 28 #include "skl-ssp-clk.h" 29 30 #define SKL_SUSPEND_DELAY 2000 31 32 #define AZX_PCIREG_PGCTL 0x44 33 #define AZX_PGCTL_LSRMD_MASK (1 << 4) 34 #define AZX_PCIREG_CGCTL 0x48 35 #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6) 36 /* D0I3C Register fields */ 37 #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */ 38 #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */ 39 40 struct skl_dsp_resource { 41 u32 max_mcps; 42 u32 max_mem; 43 u32 mcps; 44 u32 mem; 45 }; 46 47 struct skl_debug; 48 49 struct skl { 50 struct hdac_ext_bus ebus; 51 struct pci_dev *pci; 52 53 unsigned int init_done:1; /* delayed init status */ 54 struct platform_device *dmic_dev; 55 struct platform_device *i2s_dev; 56 struct platform_device *clk_dev; 57 struct snd_soc_platform *platform; 58 struct snd_soc_dai_driver *dais; 59 60 struct nhlt_acpi_table *nhlt; /* nhlt ptr */ 61 struct skl_sst *skl_sst; /* sst skl ctx */ 62 63 struct skl_dsp_resource resource; 64 struct list_head ppl_list; 65 struct list_head bind_list; 66 67 const char *fw_name; 68 char tplg_name[64]; 69 unsigned short pci_id; 70 const struct firmware *tplg; 71 72 int supend_active; 73 74 struct work_struct probe_work; 75 76 struct skl_debug *debugfs; 77 u8 nr_modules; 78 struct skl_module **modules; 79 bool use_tplg_pcm; 80 }; 81 82 #define skl_to_ebus(s) (&(s)->ebus) 83 #define ebus_to_skl(sbus) \ 84 container_of(sbus, struct skl, sbus) 85 86 /* to pass dai dma data */ 87 struct skl_dma_params { 88 u32 format; 89 u8 stream_tag; 90 }; 91 92 struct skl_machine_pdata { 93 u32 dmic_num; 94 bool use_tplg_pcm; /* use dais and dai links from topology */ 95 }; 96 97 struct skl_dsp_ops { 98 int id; 99 unsigned int num_cores; 100 struct skl_dsp_loader_ops (*loader_ops)(void); 101 int (*init)(struct device *dev, void __iomem *mmio_base, 102 int irq, const char *fw_name, 103 struct skl_dsp_loader_ops loader_ops, 104 struct skl_sst **skl_sst); 105 int (*init_fw)(struct device *dev, struct skl_sst *ctx); 106 void (*cleanup)(struct device *dev, struct skl_sst *ctx); 107 }; 108 109 int skl_platform_unregister(struct device *dev); 110 int skl_platform_register(struct device *dev); 111 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 118 int skl_get_dmic_geo(struct skl *skl); 119 int skl_nhlt_update_topology_bin(struct skl *skl); 120 int skl_init_dsp(struct skl *skl); 121 int skl_free_dsp(struct skl *skl); 122 int skl_suspend_late_dsp(struct skl *skl); 123 int skl_suspend_dsp(struct skl *skl); 124 int skl_resume_dsp(struct skl *skl); 125 void skl_cleanup_resources(struct skl *skl); 126 const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id); 127 void skl_update_d0i3c(struct device *dev, bool enable); 128 int skl_nhlt_create_sysfs(struct skl *skl); 129 void skl_nhlt_remove_sysfs(struct skl *skl); 130 void skl_get_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks); 131 struct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id); 132 133 struct skl_module_cfg; 134 135 #ifdef CONFIG_DEBUG_FS 136 struct skl_debug *skl_debugfs_init(struct skl *skl); 137 void skl_debug_init_module(struct skl_debug *d, 138 struct snd_soc_dapm_widget *w, 139 struct skl_module_cfg *mconfig); 140 #else 141 static inline struct skl_debug *skl_debugfs_init(struct skl *skl) 142 { 143 return NULL; 144 } 145 static inline void skl_debug_init_module(struct skl_debug *d, 146 struct snd_soc_dapm_widget *w, 147 struct skl_module_cfg *mconfig) 148 {} 149 #endif 150 151 #endif /* __SOUND_SOC_SKL_H */ 152