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