18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * skl.h - HD Audio skylake defintions. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2015 Intel Corp 68c2ecf20Sopenharmony_ci * Author: Jeeja KP <jeeja.kp@intel.com> 78c2ecf20Sopenharmony_ci * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __SOUND_SOC_SKL_H 138c2ecf20Sopenharmony_ci#define __SOUND_SOC_SKL_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <sound/hda_register.h> 168c2ecf20Sopenharmony_ci#include <sound/hdaudio_ext.h> 178c2ecf20Sopenharmony_ci#include <sound/hda_codec.h> 188c2ecf20Sopenharmony_ci#include <sound/soc.h> 198c2ecf20Sopenharmony_ci#include "skl-ssp-clk.h" 208c2ecf20Sopenharmony_ci#include "skl-sst-ipc.h" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define SKL_SUSPEND_DELAY 2000 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define SKL_MAX_ASTATE_CFG 3 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define AZX_PCIREG_PGCTL 0x44 278c2ecf20Sopenharmony_ci#define AZX_PGCTL_LSRMD_MASK (1 << 4) 288c2ecf20Sopenharmony_ci#define AZX_PGCTL_ADSPPGD BIT(2) 298c2ecf20Sopenharmony_ci#define AZX_PCIREG_CGCTL 0x48 308c2ecf20Sopenharmony_ci#define AZX_CGCTL_MISCBDCGE_MASK (1 << 6) 318c2ecf20Sopenharmony_ci#define AZX_CGCTL_ADSPDCGE BIT(1) 328c2ecf20Sopenharmony_ci/* D0I3C Register fields */ 338c2ecf20Sopenharmony_ci#define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */ 348c2ecf20Sopenharmony_ci#define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */ 358c2ecf20Sopenharmony_ci#define SKL_MAX_DMACTRL_CFG 18 368c2ecf20Sopenharmony_ci#define DMA_CLK_CONTROLS 1 378c2ecf20Sopenharmony_ci#define DMA_TRANSMITION_START 2 388c2ecf20Sopenharmony_ci#define DMA_TRANSMITION_STOP 3 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define AZX_VS_EM2_DUM BIT(23) 418c2ecf20Sopenharmony_ci#define AZX_REG_VS_EM2_L1SEN BIT(13) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct skl_debug; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct skl_astate_param { 468c2ecf20Sopenharmony_ci u32 kcps; 478c2ecf20Sopenharmony_ci u32 clk_src; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistruct skl_astate_config { 518c2ecf20Sopenharmony_ci u32 count; 528c2ecf20Sopenharmony_ci struct skl_astate_param astate_table[]; 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistruct skl_fw_config { 568c2ecf20Sopenharmony_ci struct skl_astate_config *astate_cfg; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct skl_dev { 608c2ecf20Sopenharmony_ci struct hda_bus hbus; 618c2ecf20Sopenharmony_ci struct pci_dev *pci; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci unsigned int init_done:1; /* delayed init status */ 648c2ecf20Sopenharmony_ci struct platform_device *dmic_dev; 658c2ecf20Sopenharmony_ci struct platform_device *i2s_dev; 668c2ecf20Sopenharmony_ci struct platform_device *clk_dev; 678c2ecf20Sopenharmony_ci struct snd_soc_component *component; 688c2ecf20Sopenharmony_ci struct snd_soc_dai_driver *dais; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci struct nhlt_acpi_table *nhlt; /* nhlt ptr */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci struct list_head ppl_list; 738c2ecf20Sopenharmony_ci struct list_head bind_list; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci const char *fw_name; 768c2ecf20Sopenharmony_ci char tplg_name[64]; 778c2ecf20Sopenharmony_ci unsigned short pci_id; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci int supend_active; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci struct work_struct probe_work; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci struct skl_debug *debugfs; 848c2ecf20Sopenharmony_ci u8 nr_modules; 858c2ecf20Sopenharmony_ci struct skl_module **modules; 868c2ecf20Sopenharmony_ci bool use_tplg_pcm; 878c2ecf20Sopenharmony_ci struct skl_fw_config cfg; 888c2ecf20Sopenharmony_ci struct snd_soc_acpi_mach *mach; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci struct device *dev; 918c2ecf20Sopenharmony_ci struct sst_dsp *dsp; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci /* boot */ 948c2ecf20Sopenharmony_ci wait_queue_head_t boot_wait; 958c2ecf20Sopenharmony_ci bool boot_complete; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci /* module load */ 988c2ecf20Sopenharmony_ci wait_queue_head_t mod_load_wait; 998c2ecf20Sopenharmony_ci bool mod_load_complete; 1008c2ecf20Sopenharmony_ci bool mod_load_status; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci /* IPC messaging */ 1038c2ecf20Sopenharmony_ci struct sst_generic_ipc ipc; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci /* callback for miscbdge */ 1068c2ecf20Sopenharmony_ci void (*enable_miscbdcge)(struct device *dev, bool enable); 1078c2ecf20Sopenharmony_ci /* Is CGCTL.MISCBDCGE disabled */ 1088c2ecf20Sopenharmony_ci bool miscbdcg_disabled; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /* Populate module information */ 1118c2ecf20Sopenharmony_ci struct list_head uuid_list; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci /* Is firmware loaded */ 1148c2ecf20Sopenharmony_ci bool fw_loaded; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci /* first boot ? */ 1178c2ecf20Sopenharmony_ci bool is_first_boot; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci /* multi-core */ 1208c2ecf20Sopenharmony_ci struct skl_dsp_cores cores; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci /* library info */ 1238c2ecf20Sopenharmony_ci struct skl_lib_info lib_info[SKL_MAX_LIB]; 1248c2ecf20Sopenharmony_ci int lib_count; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci /* Callback to update D0i3C register */ 1278c2ecf20Sopenharmony_ci void (*update_d0i3c)(struct device *dev, bool enable); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci struct skl_d0i3_data d0i3; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci const struct skl_dsp_ops *dsp_ops; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci /* Callback to update dynamic clock and power gating registers */ 1348c2ecf20Sopenharmony_ci void (*clock_power_gating)(struct device *dev, bool enable); 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define skl_to_bus(s) (&(s)->hbus.core) 1388c2ecf20Sopenharmony_ci#define bus_to_skl(bus) container_of(bus, struct skl_dev, hbus.core) 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define skl_to_hbus(s) (&(s)->hbus) 1418c2ecf20Sopenharmony_ci#define hbus_to_skl(hbus) container_of((hbus), struct skl_dev, (hbus)) 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* to pass dai dma data */ 1448c2ecf20Sopenharmony_cistruct skl_dma_params { 1458c2ecf20Sopenharmony_ci u32 format; 1468c2ecf20Sopenharmony_ci u8 stream_tag; 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistruct skl_machine_pdata { 1508c2ecf20Sopenharmony_ci bool use_tplg_pcm; /* use dais and dai links from topology */ 1518c2ecf20Sopenharmony_ci}; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cistruct skl_dsp_ops { 1548c2ecf20Sopenharmony_ci int id; 1558c2ecf20Sopenharmony_ci unsigned int num_cores; 1568c2ecf20Sopenharmony_ci struct skl_dsp_loader_ops (*loader_ops)(void); 1578c2ecf20Sopenharmony_ci int (*init)(struct device *dev, void __iomem *mmio_base, 1588c2ecf20Sopenharmony_ci int irq, const char *fw_name, 1598c2ecf20Sopenharmony_ci struct skl_dsp_loader_ops loader_ops, 1608c2ecf20Sopenharmony_ci struct skl_dev **skl_sst); 1618c2ecf20Sopenharmony_ci int (*init_fw)(struct device *dev, struct skl_dev *skl); 1628c2ecf20Sopenharmony_ci void (*cleanup)(struct device *dev, struct skl_dev *skl); 1638c2ecf20Sopenharmony_ci}; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ciint skl_platform_unregister(struct device *dev); 1668c2ecf20Sopenharmony_ciint skl_platform_register(struct device *dev); 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cistruct nhlt_specific_cfg *skl_get_ep_blob(struct skl_dev *skl, u32 instance, 1698c2ecf20Sopenharmony_ci u8 link_type, u8 s_fmt, u8 num_ch, 1708c2ecf20Sopenharmony_ci u32 s_rate, u8 dirn, u8 dev_type); 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ciint skl_nhlt_update_topology_bin(struct skl_dev *skl); 1738c2ecf20Sopenharmony_ciint skl_init_dsp(struct skl_dev *skl); 1748c2ecf20Sopenharmony_ciint skl_free_dsp(struct skl_dev *skl); 1758c2ecf20Sopenharmony_ciint skl_suspend_late_dsp(struct skl_dev *skl); 1768c2ecf20Sopenharmony_ciint skl_suspend_dsp(struct skl_dev *skl); 1778c2ecf20Sopenharmony_ciint skl_resume_dsp(struct skl_dev *skl); 1788c2ecf20Sopenharmony_civoid skl_cleanup_resources(struct skl_dev *skl); 1798c2ecf20Sopenharmony_ciconst struct skl_dsp_ops *skl_get_dsp_ops(int pci_id); 1808c2ecf20Sopenharmony_civoid skl_update_d0i3c(struct device *dev, bool enable); 1818c2ecf20Sopenharmony_ciint skl_nhlt_create_sysfs(struct skl_dev *skl); 1828c2ecf20Sopenharmony_civoid skl_nhlt_remove_sysfs(struct skl_dev *skl); 1838c2ecf20Sopenharmony_civoid skl_get_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks); 1848c2ecf20Sopenharmony_cistruct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id); 1858c2ecf20Sopenharmony_ciint skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps, 1868c2ecf20Sopenharmony_ci u32 caps_size, u32 node_id); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_cistruct skl_module_cfg; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 1918c2ecf20Sopenharmony_cistruct skl_debug *skl_debugfs_init(struct skl_dev *skl); 1928c2ecf20Sopenharmony_civoid skl_debugfs_exit(struct skl_dev *skl); 1938c2ecf20Sopenharmony_civoid skl_debug_init_module(struct skl_debug *d, 1948c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w, 1958c2ecf20Sopenharmony_ci struct skl_module_cfg *mconfig); 1968c2ecf20Sopenharmony_ci#else 1978c2ecf20Sopenharmony_cistatic inline struct skl_debug *skl_debugfs_init(struct skl_dev *skl) 1988c2ecf20Sopenharmony_ci{ 1998c2ecf20Sopenharmony_ci return NULL; 2008c2ecf20Sopenharmony_ci} 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_cistatic inline void skl_debugfs_exit(struct skl_dev *skl) 2038c2ecf20Sopenharmony_ci{} 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_cistatic inline void skl_debug_init_module(struct skl_debug *d, 2068c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *w, 2078c2ecf20Sopenharmony_ci struct skl_module_cfg *mconfig) 2088c2ecf20Sopenharmony_ci{} 2098c2ecf20Sopenharmony_ci#endif 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci#endif /* __SOUND_SOC_SKL_H */ 212