162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 462306a36Sopenharmony_ci * redistributing this file, you may do so under either license. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright(c) 2017 Intel Corporation. All rights reserved. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef __SOF_INTEL_SHIM_H 1262306a36Sopenharmony_ci#define __SOF_INTEL_SHIM_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cienum sof_intel_hw_ip_version { 1562306a36Sopenharmony_ci SOF_INTEL_TANGIER, 1662306a36Sopenharmony_ci SOF_INTEL_BAYTRAIL, 1762306a36Sopenharmony_ci SOF_INTEL_BROADWELL, 1862306a36Sopenharmony_ci SOF_INTEL_CAVS_1_5, /* SkyLake, KabyLake, AmberLake */ 1962306a36Sopenharmony_ci SOF_INTEL_CAVS_1_5_PLUS,/* ApolloLake, GeminiLake */ 2062306a36Sopenharmony_ci SOF_INTEL_CAVS_1_8, /* CannonLake, CometLake, CoffeeLake */ 2162306a36Sopenharmony_ci SOF_INTEL_CAVS_2_0, /* IceLake, JasperLake */ 2262306a36Sopenharmony_ci SOF_INTEL_CAVS_2_5, /* TigerLake, AlderLake */ 2362306a36Sopenharmony_ci SOF_INTEL_ACE_1_0, /* MeteorLake */ 2462306a36Sopenharmony_ci SOF_INTEL_ACE_2_0, /* LunarLake */ 2562306a36Sopenharmony_ci}; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* 2862306a36Sopenharmony_ci * SHIM registers for BYT, BSW, CHT, BDW 2962306a36Sopenharmony_ci */ 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define SHIM_CSR (SHIM_OFFSET + 0x00) 3262306a36Sopenharmony_ci#define SHIM_PISR (SHIM_OFFSET + 0x08) 3362306a36Sopenharmony_ci#define SHIM_PIMR (SHIM_OFFSET + 0x10) 3462306a36Sopenharmony_ci#define SHIM_ISRX (SHIM_OFFSET + 0x18) 3562306a36Sopenharmony_ci#define SHIM_ISRD (SHIM_OFFSET + 0x20) 3662306a36Sopenharmony_ci#define SHIM_IMRX (SHIM_OFFSET + 0x28) 3762306a36Sopenharmony_ci#define SHIM_IMRD (SHIM_OFFSET + 0x30) 3862306a36Sopenharmony_ci#define SHIM_IPCX (SHIM_OFFSET + 0x38) 3962306a36Sopenharmony_ci#define SHIM_IPCD (SHIM_OFFSET + 0x40) 4062306a36Sopenharmony_ci#define SHIM_ISRSC (SHIM_OFFSET + 0x48) 4162306a36Sopenharmony_ci#define SHIM_ISRLPESC (SHIM_OFFSET + 0x50) 4262306a36Sopenharmony_ci#define SHIM_IMRSC (SHIM_OFFSET + 0x58) 4362306a36Sopenharmony_ci#define SHIM_IMRLPESC (SHIM_OFFSET + 0x60) 4462306a36Sopenharmony_ci#define SHIM_IPCSC (SHIM_OFFSET + 0x68) 4562306a36Sopenharmony_ci#define SHIM_IPCLPESC (SHIM_OFFSET + 0x70) 4662306a36Sopenharmony_ci#define SHIM_CLKCTL (SHIM_OFFSET + 0x78) 4762306a36Sopenharmony_ci#define SHIM_CSR2 (SHIM_OFFSET + 0x80) 4862306a36Sopenharmony_ci#define SHIM_LTRC (SHIM_OFFSET + 0xE0) 4962306a36Sopenharmony_ci#define SHIM_HMDC (SHIM_OFFSET + 0xE8) 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define SHIM_PWMCTRL 0x1000 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/* 5462306a36Sopenharmony_ci * SST SHIM register bits for BYT, BSW, CHT, BDW 5562306a36Sopenharmony_ci * Register bit naming and functionaility can differ between devices. 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci/* CSR / CS */ 5962306a36Sopenharmony_ci#define SHIM_CSR_RST BIT(1) 6062306a36Sopenharmony_ci#define SHIM_CSR_SBCS0 BIT(2) 6162306a36Sopenharmony_ci#define SHIM_CSR_SBCS1 BIT(3) 6262306a36Sopenharmony_ci#define SHIM_CSR_DCS(x) ((x) << 4) 6362306a36Sopenharmony_ci#define SHIM_CSR_DCS_MASK (0x7 << 4) 6462306a36Sopenharmony_ci#define SHIM_CSR_STALL BIT(10) 6562306a36Sopenharmony_ci#define SHIM_CSR_S0IOCS BIT(21) 6662306a36Sopenharmony_ci#define SHIM_CSR_S1IOCS BIT(23) 6762306a36Sopenharmony_ci#define SHIM_CSR_LPCS BIT(31) 6862306a36Sopenharmony_ci#define SHIM_CSR_24MHZ_LPCS \ 6962306a36Sopenharmony_ci (SHIM_CSR_SBCS0 | SHIM_CSR_SBCS1 | SHIM_CSR_LPCS) 7062306a36Sopenharmony_ci#define SHIM_CSR_24MHZ_NO_LPCS (SHIM_CSR_SBCS0 | SHIM_CSR_SBCS1) 7162306a36Sopenharmony_ci#define SHIM_BYT_CSR_RST BIT(0) 7262306a36Sopenharmony_ci#define SHIM_BYT_CSR_VECTOR_SEL BIT(1) 7362306a36Sopenharmony_ci#define SHIM_BYT_CSR_STALL BIT(2) 7462306a36Sopenharmony_ci#define SHIM_BYT_CSR_PWAITMODE BIT(3) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* ISRX / ISC */ 7762306a36Sopenharmony_ci#define SHIM_ISRX_BUSY BIT(1) 7862306a36Sopenharmony_ci#define SHIM_ISRX_DONE BIT(0) 7962306a36Sopenharmony_ci#define SHIM_BYT_ISRX_REQUEST BIT(1) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* ISRD / ISD */ 8262306a36Sopenharmony_ci#define SHIM_ISRD_BUSY BIT(1) 8362306a36Sopenharmony_ci#define SHIM_ISRD_DONE BIT(0) 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci/* IMRX / IMC */ 8662306a36Sopenharmony_ci#define SHIM_IMRX_BUSY BIT(1) 8762306a36Sopenharmony_ci#define SHIM_IMRX_DONE BIT(0) 8862306a36Sopenharmony_ci#define SHIM_BYT_IMRX_REQUEST BIT(1) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* IMRD / IMD */ 9162306a36Sopenharmony_ci#define SHIM_IMRD_DONE BIT(0) 9262306a36Sopenharmony_ci#define SHIM_IMRD_BUSY BIT(1) 9362306a36Sopenharmony_ci#define SHIM_IMRD_SSP0 BIT(16) 9462306a36Sopenharmony_ci#define SHIM_IMRD_DMAC0 BIT(21) 9562306a36Sopenharmony_ci#define SHIM_IMRD_DMAC1 BIT(22) 9662306a36Sopenharmony_ci#define SHIM_IMRD_DMAC (SHIM_IMRD_DMAC0 | SHIM_IMRD_DMAC1) 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci/* IPCX / IPCC */ 9962306a36Sopenharmony_ci#define SHIM_IPCX_DONE BIT(30) 10062306a36Sopenharmony_ci#define SHIM_IPCX_BUSY BIT(31) 10162306a36Sopenharmony_ci#define SHIM_BYT_IPCX_DONE BIT_ULL(62) 10262306a36Sopenharmony_ci#define SHIM_BYT_IPCX_BUSY BIT_ULL(63) 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* IPCD */ 10562306a36Sopenharmony_ci#define SHIM_IPCD_DONE BIT(30) 10662306a36Sopenharmony_ci#define SHIM_IPCD_BUSY BIT(31) 10762306a36Sopenharmony_ci#define SHIM_BYT_IPCD_DONE BIT_ULL(62) 10862306a36Sopenharmony_ci#define SHIM_BYT_IPCD_BUSY BIT_ULL(63) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* CLKCTL */ 11162306a36Sopenharmony_ci#define SHIM_CLKCTL_SMOS(x) ((x) << 24) 11262306a36Sopenharmony_ci#define SHIM_CLKCTL_MASK (3 << 24) 11362306a36Sopenharmony_ci#define SHIM_CLKCTL_DCPLCG BIT(18) 11462306a36Sopenharmony_ci#define SHIM_CLKCTL_SCOE1 BIT(17) 11562306a36Sopenharmony_ci#define SHIM_CLKCTL_SCOE0 BIT(16) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci/* CSR2 / CS2 */ 11862306a36Sopenharmony_ci#define SHIM_CSR2_SDFD_SSP0 BIT(1) 11962306a36Sopenharmony_ci#define SHIM_CSR2_SDFD_SSP1 BIT(2) 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* LTRC */ 12262306a36Sopenharmony_ci#define SHIM_LTRC_VAL(x) ((x) << 0) 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci/* HMDC */ 12562306a36Sopenharmony_ci#define SHIM_HMDC_HDDA0(x) ((x) << 0) 12662306a36Sopenharmony_ci#define SHIM_HMDC_HDDA1(x) ((x) << 7) 12762306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH0 1 12862306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH1 2 12962306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH2 4 13062306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH3 8 13162306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH0 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH0) 13262306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH1 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH1) 13362306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH2 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH2) 13462306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH3 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH3) 13562306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_ALLCH \ 13662306a36Sopenharmony_ci (SHIM_HMDC_HDDA_E0_CH0 | SHIM_HMDC_HDDA_E0_CH1 | \ 13762306a36Sopenharmony_ci SHIM_HMDC_HDDA_E0_CH2 | SHIM_HMDC_HDDA_E0_CH3) 13862306a36Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_ALLCH \ 13962306a36Sopenharmony_ci (SHIM_HMDC_HDDA_E1_CH0 | SHIM_HMDC_HDDA_E1_CH1 | \ 14062306a36Sopenharmony_ci SHIM_HMDC_HDDA_E1_CH2 | SHIM_HMDC_HDDA_E1_CH3) 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci/* Audio DSP PCI registers */ 14362306a36Sopenharmony_ci#define PCI_VDRTCTL0 0xa0 14462306a36Sopenharmony_ci#define PCI_VDRTCTL1 0xa4 14562306a36Sopenharmony_ci#define PCI_VDRTCTL2 0xa8 14662306a36Sopenharmony_ci#define PCI_VDRTCTL3 0xaC 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/* VDRTCTL0 */ 14962306a36Sopenharmony_ci#define PCI_VDRTCL0_D3PGD BIT(0) 15062306a36Sopenharmony_ci#define PCI_VDRTCL0_D3SRAMPGD BIT(1) 15162306a36Sopenharmony_ci#define PCI_VDRTCL0_DSRAMPGE_SHIFT 12 15262306a36Sopenharmony_ci#define PCI_VDRTCL0_DSRAMPGE_MASK GENMASK(PCI_VDRTCL0_DSRAMPGE_SHIFT + 19,\ 15362306a36Sopenharmony_ci PCI_VDRTCL0_DSRAMPGE_SHIFT) 15462306a36Sopenharmony_ci#define PCI_VDRTCL0_ISRAMPGE_SHIFT 2 15562306a36Sopenharmony_ci#define PCI_VDRTCL0_ISRAMPGE_MASK GENMASK(PCI_VDRTCL0_ISRAMPGE_SHIFT + 9,\ 15662306a36Sopenharmony_ci PCI_VDRTCL0_ISRAMPGE_SHIFT) 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci/* VDRTCTL2 */ 15962306a36Sopenharmony_ci#define PCI_VDRTCL2_DCLCGE BIT(1) 16062306a36Sopenharmony_ci#define PCI_VDRTCL2_DTCGE BIT(10) 16162306a36Sopenharmony_ci#define PCI_VDRTCL2_APLLSE_MASK BIT(31) 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci/* PMCS */ 16462306a36Sopenharmony_ci#define PCI_PMCS 0x84 16562306a36Sopenharmony_ci#define PCI_PMCS_PS_MASK 0x3 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci/* Intel quirks */ 16862306a36Sopenharmony_ci#define SOF_INTEL_PROCEN_FMT_QUIRK BIT(0) 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci/* DSP hardware descriptor */ 17162306a36Sopenharmony_cistruct sof_intel_dsp_desc { 17262306a36Sopenharmony_ci int cores_num; 17362306a36Sopenharmony_ci int host_managed_cores_mask; 17462306a36Sopenharmony_ci int init_core_mask; /* cores available after fw boot */ 17562306a36Sopenharmony_ci int ipc_req; 17662306a36Sopenharmony_ci int ipc_req_mask; 17762306a36Sopenharmony_ci int ipc_ack; 17862306a36Sopenharmony_ci int ipc_ack_mask; 17962306a36Sopenharmony_ci int ipc_ctl; 18062306a36Sopenharmony_ci int rom_status_reg; 18162306a36Sopenharmony_ci int rom_init_timeout; 18262306a36Sopenharmony_ci int ssp_count; /* ssp count of the platform */ 18362306a36Sopenharmony_ci int ssp_base_offset; /* base address of the SSPs */ 18462306a36Sopenharmony_ci u32 sdw_shim_base; 18562306a36Sopenharmony_ci u32 sdw_alh_base; 18662306a36Sopenharmony_ci u32 d0i3_offset; 18762306a36Sopenharmony_ci u32 quirks; 18862306a36Sopenharmony_ci enum sof_intel_hw_ip_version hw_ip_version; 18962306a36Sopenharmony_ci int (*read_sdw_lcount)(struct snd_sof_dev *sdev); 19062306a36Sopenharmony_ci void (*enable_sdw_irq)(struct snd_sof_dev *sdev, bool enable); 19162306a36Sopenharmony_ci bool (*check_sdw_irq)(struct snd_sof_dev *sdev); 19262306a36Sopenharmony_ci bool (*check_sdw_wakeen_irq)(struct snd_sof_dev *sdev); 19362306a36Sopenharmony_ci bool (*check_ipc_irq)(struct snd_sof_dev *sdev); 19462306a36Sopenharmony_ci int (*power_down_dsp)(struct snd_sof_dev *sdev); 19562306a36Sopenharmony_ci int (*disable_interrupts)(struct snd_sof_dev *sdev); 19662306a36Sopenharmony_ci int (*cl_init)(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot); 19762306a36Sopenharmony_ci}; 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_tng_ops; 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc tng_chip_info; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_cistruct sof_intel_stream { 20462306a36Sopenharmony_ci size_t posn_offset; 20562306a36Sopenharmony_ci}; 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_cistatic inline const struct sof_intel_dsp_desc *get_chip_info(struct snd_sof_pdata *pdata) 20862306a36Sopenharmony_ci{ 20962306a36Sopenharmony_ci const struct sof_dev_desc *desc = pdata->desc; 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci return desc->chip_info; 21262306a36Sopenharmony_ci} 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci#endif 215