1392f1045SVinod Koul /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 2392f1045SVinod Koul /* Copyright(c) 2015-17 Intel Corporation. */ 371bb8a1bSVinod Koul 471bb8a1bSVinod Koul #ifndef __SDW_INTEL_H 571bb8a1bSVinod Koul #define __SDW_INTEL_H 671bb8a1bSVinod Koul 76cd1d670SBard Liao #include <linux/irqreturn.h> 892f622bcSBard Liao #include <linux/soundwire/sdw.h> 96cd1d670SBard Liao 1027c433ceSPierre-Louis Bossart /********************************************************************* 1127c433ceSPierre-Louis Bossart * cAVS and ACE1.x definitions 1227c433ceSPierre-Louis Bossart *********************************************************************/ 1327c433ceSPierre-Louis Bossart 14f0163958SBard Liao #define SDW_SHIM_BASE 0x2C000 15f0163958SBard Liao #define SDW_ALH_BASE 0x2C800 16064520e8SBard Liao #define SDW_SHIM_BASE_ACE 0x38000 17064520e8SBard Liao #define SDW_ALH_BASE_ACE 0x24000 18f0163958SBard Liao #define SDW_LINK_BASE 0x30000 19f0163958SBard Liao #define SDW_LINK_SIZE 0x10000 20f0163958SBard Liao 21f0163958SBard Liao /* Intel SHIM Registers Definition */ 227f817068SPierre-Louis Bossart /* LCAP */ 23f0163958SBard Liao #define SDW_SHIM_LCAP 0x0 247f817068SPierre-Louis Bossart #define SDW_SHIM_LCAP_LCOUNT_MASK GENMASK(2, 0) 257f817068SPierre-Louis Bossart 26feaa24aaSPierre-Louis Bossart /* LCTL */ 27f0163958SBard Liao #define SDW_SHIM_LCTL 0x4 28feaa24aaSPierre-Louis Bossart 29feaa24aaSPierre-Louis Bossart #define SDW_SHIM_LCTL_SPA BIT(0) 30feaa24aaSPierre-Louis Bossart #define SDW_SHIM_LCTL_SPA_MASK GENMASK(3, 0) 31feaa24aaSPierre-Louis Bossart #define SDW_SHIM_LCTL_CPA BIT(8) 32feaa24aaSPierre-Louis Bossart #define SDW_SHIM_LCTL_CPA_MASK GENMASK(11, 8) 33feaa24aaSPierre-Louis Bossart 34ca33a58dSPierre-Louis Bossart /* SYNC */ 35f0163958SBard Liao #define SDW_SHIM_SYNC 0xC 36f0163958SBard Liao 37ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_SYNCPRD_VAL_24 (24000 / SDW_CADENCE_GSYNC_KHZ - 1) 38ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_SYNCPRD_VAL_38_4 (38400 / SDW_CADENCE_GSYNC_KHZ - 1) 39ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_SYNCPRD GENMASK(14, 0) 40ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_SYNCCPU BIT(15) 41ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_CMDSYNC_MASK GENMASK(19, 16) 42ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_CMDSYNC BIT(16) 43ca33a58dSPierre-Louis Bossart #define SDW_SHIM_SYNC_SYNCGO BIT(24) 44ca33a58dSPierre-Louis Bossart 45bd45a65dSPierre-Louis Bossart /* Control stream capabililities and channel mask */ 46f0163958SBard Liao #define SDW_SHIM_CTLSCAP(x) (0x010 + 0x60 * (x)) 47f0163958SBard Liao #define SDW_SHIM_CTLS0CM(x) (0x012 + 0x60 * (x)) 48f0163958SBard Liao #define SDW_SHIM_CTLS1CM(x) (0x014 + 0x60 * (x)) 49f0163958SBard Liao #define SDW_SHIM_CTLS2CM(x) (0x016 + 0x60 * (x)) 50f0163958SBard Liao #define SDW_SHIM_CTLS3CM(x) (0x018 + 0x60 * (x)) 51bd45a65dSPierre-Louis Bossart 5240f7a3ddSPierre-Louis Bossart /* PCM Stream capabilities */ 53f0163958SBard Liao #define SDW_SHIM_PCMSCAP(x) (0x020 + 0x60 * (x)) 54f0163958SBard Liao 5540f7a3ddSPierre-Louis Bossart #define SDW_SHIM_PCMSCAP_ISS GENMASK(3, 0) 5640f7a3ddSPierre-Louis Bossart #define SDW_SHIM_PCMSCAP_OSS GENMASK(7, 4) 5740f7a3ddSPierre-Louis Bossart #define SDW_SHIM_PCMSCAP_BSS GENMASK(12, 8) 5840f7a3ddSPierre-Louis Bossart 595c0d2562SPierre-Louis Bossart /* PCM Stream Channel Map */ 60f0163958SBard Liao #define SDW_SHIM_PCMSYCHM(x, y) (0x022 + (0x60 * (x)) + (0x2 * (y))) 61f0163958SBard Liao 625c0d2562SPierre-Louis Bossart /* PCM Stream Channel Count */ 635c0d2562SPierre-Louis Bossart #define SDW_SHIM_PCMSYCHC(x, y) (0x042 + (0x60 * (x)) + (0x2 * (y))) 64f0163958SBard Liao 65f0163958SBard Liao #define SDW_SHIM_PCMSYCM_LCHN GENMASK(3, 0) 66f0163958SBard Liao #define SDW_SHIM_PCMSYCM_HCHN GENMASK(7, 4) 67f0163958SBard Liao #define SDW_SHIM_PCMSYCM_STREAM GENMASK(13, 8) 68f0163958SBard Liao #define SDW_SHIM_PCMSYCM_DIR BIT(15) 69f0163958SBard Liao 703ea29d33SPierre-Louis Bossart /* IO control */ 715c0d2562SPierre-Louis Bossart #define SDW_SHIM_IOCTL(x) (0x06C + 0x60 * (x)) 725c0d2562SPierre-Louis Bossart 73f0163958SBard Liao #define SDW_SHIM_IOCTL_MIF BIT(0) 74f0163958SBard Liao #define SDW_SHIM_IOCTL_CO BIT(1) 75f0163958SBard Liao #define SDW_SHIM_IOCTL_COE BIT(2) 76f0163958SBard Liao #define SDW_SHIM_IOCTL_DO BIT(3) 77f0163958SBard Liao #define SDW_SHIM_IOCTL_DOE BIT(4) 78f0163958SBard Liao #define SDW_SHIM_IOCTL_BKE BIT(5) 79f0163958SBard Liao #define SDW_SHIM_IOCTL_WPDD BIT(6) 80f0163958SBard Liao #define SDW_SHIM_IOCTL_CIBD BIT(8) 81f0163958SBard Liao #define SDW_SHIM_IOCTL_DIBD BIT(9) 82f0163958SBard Liao 83279e46bcSPierre-Louis Bossart /* Wake Enable*/ 843ea29d33SPierre-Louis Bossart #define SDW_SHIM_WAKEEN 0x190 85279e46bcSPierre-Louis Bossart 86279e46bcSPierre-Louis Bossart #define SDW_SHIM_WAKEEN_ENABLE BIT(0) 87279e46bcSPierre-Louis Bossart 88279e46bcSPierre-Louis Bossart /* Wake Status */ 893ea29d33SPierre-Louis Bossart #define SDW_SHIM_WAKESTS 0x192 903ea29d33SPierre-Louis Bossart 91279e46bcSPierre-Louis Bossart #define SDW_SHIM_WAKESTS_STATUS BIT(0) 92279e46bcSPierre-Louis Bossart 93bc7b9595SPierre-Louis Bossart /* AC Timing control */ 94bc7b9595SPierre-Louis Bossart #define SDW_SHIM_CTMCTL(x) (0x06E + 0x60 * (x)) 95bc7b9595SPierre-Louis Bossart 96f0163958SBard Liao #define SDW_SHIM_CTMCTL_DACTQE BIT(0) 97f0163958SBard Liao #define SDW_SHIM_CTMCTL_DODS BIT(1) 98f0163958SBard Liao #define SDW_SHIM_CTMCTL_DOAIS GENMASK(4, 3) 99f0163958SBard Liao 100f0163958SBard Liao /* Intel ALH Register definitions */ 101f0163958SBard Liao #define SDW_ALH_STRMZCFG(x) (0x000 + (0x4 * (x))) 102f0163958SBard Liao #define SDW_ALH_NUM_STREAMS 64 103f0163958SBard Liao 104f0163958SBard Liao #define SDW_ALH_STRMZCFG_DMAT_VAL 0x3 105f0163958SBard Liao #define SDW_ALH_STRMZCFG_DMAT GENMASK(7, 0) 106f0163958SBard Liao #define SDW_ALH_STRMZCFG_CHN GENMASK(19, 16) 107f0163958SBard Liao 10827c433ceSPierre-Louis Bossart /********************************************************************* 10927c433ceSPierre-Louis Bossart * ACE2.x definitions for SHIM registers - only accessible when the 11027c433ceSPierre-Louis Bossart * HDAudio extended link LCTL.SPA/CPA = 1. 11127c433ceSPierre-Louis Bossart *********************************************************************/ 11227c433ceSPierre-Louis Bossart /* x variable is link index */ 11327c433ceSPierre-Louis Bossart #define SDW_SHIM2_GENERIC_BASE(x) (0x00030000 + 0x8000 * (x)) 11427c433ceSPierre-Louis Bossart #define SDW_IP_BASE(x) (0x00030100 + 0x8000 * (x)) 11527c433ceSPierre-Louis Bossart #define SDW_SHIM2_VS_BASE(x) (0x00036000 + 0x8000 * (x)) 11627c433ceSPierre-Louis Bossart 11727c433ceSPierre-Louis Bossart /* SHIM2 Generic Registers */ 11827c433ceSPierre-Louis Bossart /* Read-only capabilities */ 11927c433ceSPierre-Louis Bossart #define SDW_SHIM2_LECAP 0x00 12027c433ceSPierre-Louis Bossart #define SDW_SHIM2_LECAP_HDS BIT(0) /* unset -> Host mode */ 12127c433ceSPierre-Louis Bossart #define SDW_SHIM2_LECAP_MLC GENMASK(3, 1) /* Number of Lanes */ 12227c433ceSPierre-Louis Bossart 12327c433ceSPierre-Louis Bossart /* PCM Stream capabilities */ 12427c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSCAP 0x10 12527c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSCAP_ISS GENMASK(3, 0) /* Input-only streams */ 12627c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSCAP_OSS GENMASK(7, 4) /* Output-only streams */ 12727c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSCAP_BSS GENMASK(12, 8) /* Bidirectional streams */ 12827c433ceSPierre-Louis Bossart 12927c433ceSPierre-Louis Bossart /* Read-only PCM Stream Channel Count, y variable is stream */ 13027c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHC(y) (0x14 + (0x4 * (y))) 13127c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHC_CS GENMASK(3, 0) /* Channels Supported */ 13227c433ceSPierre-Louis Bossart 13327c433ceSPierre-Louis Bossart /* PCM Stream Channel Map */ 13427c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHM(y) (0x16 + (0x4 * (y))) 13527c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHM_LCHAN GENMASK(3, 0) /* Lowest channel used by the FIFO port */ 13627c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHM_HCHAN GENMASK(7, 4) /* Lowest channel used by the FIFO port */ 13727c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHM_STRM GENMASK(13, 8) /* HDaudio stream tag */ 13827c433ceSPierre-Louis Bossart #define SDW_SHIM2_PCMSYCHM_DIR BIT(15) /* HDaudio stream direction */ 13927c433ceSPierre-Louis Bossart 14027c433ceSPierre-Louis Bossart /* SHIM2 vendor-specific registers */ 14127c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_LVSCTL 0x04 14227c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_LVSCTL_FCG BIT(26) 14327c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_LVSCTL_MLCS GENMASK(29, 27) 14427c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_LVSCTL_DCGD BIT(30) 14527c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_LVSCTL_ICGD BIT(31) 14627c433ceSPierre-Louis Bossart 14727c433ceSPierre-Louis Bossart #define SDW_SHIM2_MLCS_XTAL_CLK 0x0 14827c433ceSPierre-Louis Bossart #define SDW_SHIM2_MLCS_CARDINAL_CLK 0x1 14927c433ceSPierre-Louis Bossart #define SDW_SHIM2_MLCS_AUDIO_PLL_CLK 0x2 15027c433ceSPierre-Louis Bossart #define SDW_SHIM2_MLCS_MCLK_INPUT_CLK 0x3 15127c433ceSPierre-Louis Bossart #define SDW_SHIM2_MLCS_WOV_RING_OSC_CLK 0x4 15227c433ceSPierre-Louis Bossart 15327c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_WAKEEN 0x08 15427c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_WAKEEN_PWE BIT(0) 15527c433ceSPierre-Louis Bossart 15627c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_WAKESTS 0x0A 15727c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_WAKEEN_PWS BIT(0) 15827c433ceSPierre-Louis Bossart 15927c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL 0x0C 16027c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_MIF BIT(0) 16127c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_CO BIT(1) 16227c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_COE BIT(2) 16327c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_DO BIT(3) 16427c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_DOE BIT(4) 16527c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_BKE BIT(5) 16627c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_WPDD BIT(6) 16727c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_ODC BIT(7) 16827c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_CIBD BIT(8) 16927c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_DIBD BIT(9) 17027c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_IOCTL_HAMIFD BIT(10) 17127c433ceSPierre-Louis Bossart 17227c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_ACTMCTL 0x0E 17327c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_ACTMCTL_DACTQE BIT(0) 17427c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_ACTMCTL_DODS BIT(1) 17527c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_ACTMCTL_DODSE BIT(2) 17627c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_ACTMCTL_DOAIS GENMASK(4, 3) 17727c433ceSPierre-Louis Bossart #define SDW_SHIM2_INTEL_VS_ACTMCTL_DOAISE BIT(5) 17827c433ceSPierre-Louis Bossart 17971bb8a1bSVinod Koul /** 1804b206d34SRander Wang * struct sdw_intel_stream_params_data: configuration passed during 1814b206d34SRander Wang * the @params_stream callback, e.g. for interaction with DSP 1824b206d34SRander Wang * firmware. 1834b206d34SRander Wang */ 1844b206d34SRander Wang struct sdw_intel_stream_params_data { 1851d905d35SPierre-Louis Bossart struct snd_pcm_substream *substream; 1864b206d34SRander Wang struct snd_soc_dai *dai; 1874b206d34SRander Wang struct snd_pcm_hw_params *hw_params; 1884b206d34SRander Wang int link_id; 1894b206d34SRander Wang int alh_stream_id; 1904b206d34SRander Wang }; 1914b206d34SRander Wang 1924b206d34SRander Wang /** 1934b206d34SRander Wang * struct sdw_intel_stream_free_data: configuration passed during 1944b206d34SRander Wang * the @free_stream callback, e.g. for interaction with DSP 1954b206d34SRander Wang * firmware. 1964b206d34SRander Wang */ 1974b206d34SRander Wang struct sdw_intel_stream_free_data { 1986dd0776dSPierre-Louis Bossart struct snd_pcm_substream *substream; 1994b206d34SRander Wang struct snd_soc_dai *dai; 2004b206d34SRander Wang int link_id; 2014b206d34SRander Wang }; 2024b206d34SRander Wang 2034b206d34SRander Wang /** 204c46302ecSVinod Koul * struct sdw_intel_ops: Intel audio driver callback ops 205c46302ecSVinod Koul * 206c46302ecSVinod Koul */ 207c46302ecSVinod Koul struct sdw_intel_ops { 2084b206d34SRander Wang int (*params_stream)(struct device *dev, 2094b206d34SRander Wang struct sdw_intel_stream_params_data *params_data); 2104b206d34SRander Wang int (*free_stream)(struct device *dev, 2114b206d34SRander Wang struct sdw_intel_stream_free_data *free_data); 2128bff8c49SPierre-Louis Bossart int (*trigger)(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai); 213c46302ecSVinod Koul }; 214c46302ecSVinod Koul 215c46302ecSVinod Koul /** 216f98f690fSPierre-Louis Bossart * struct sdw_intel_acpi_info - Soundwire Intel information found in ACPI tables 217f98f690fSPierre-Louis Bossart * @handle: ACPI controller handle 218f98f690fSPierre-Louis Bossart * @count: link count found with "sdw-master-count" property 219f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing links enabled by BIOS menu 220f98f690fSPierre-Louis Bossart * 221f98f690fSPierre-Louis Bossart * this structure could be expanded to e.g. provide all the _ADR 222f98f690fSPierre-Louis Bossart * information in case the link_mask is not sufficient to identify 223f98f690fSPierre-Louis Bossart * platform capabilities. 224f98f690fSPierre-Louis Bossart */ 225f98f690fSPierre-Louis Bossart struct sdw_intel_acpi_info { 226f98f690fSPierre-Louis Bossart acpi_handle handle; 227f98f690fSPierre-Louis Bossart int count; 228f98f690fSPierre-Louis Bossart u32 link_mask; 229f98f690fSPierre-Louis Bossart }; 230f98f690fSPierre-Louis Bossart 23129a269c6SPierre-Louis Bossart struct sdw_intel_link_dev; 232f98f690fSPierre-Louis Bossart 23309f6a72dSPierre-Louis Bossart /* Intel clock-stop/pm_runtime quirk definitions */ 23409f6a72dSPierre-Louis Bossart 23509f6a72dSPierre-Louis Bossart /* 23609f6a72dSPierre-Louis Bossart * Force the clock to remain on during pm_runtime suspend. This might 23709f6a72dSPierre-Louis Bossart * be needed if Slave devices do not have an alternate clock source or 23809f6a72dSPierre-Louis Bossart * if the latency requirements are very strict. 23909f6a72dSPierre-Louis Bossart */ 24009f6a72dSPierre-Louis Bossart #define SDW_INTEL_CLK_STOP_NOT_ALLOWED BIT(0) 24109f6a72dSPierre-Louis Bossart 24209f6a72dSPierre-Louis Bossart /* 24309f6a72dSPierre-Louis Bossart * Stop the bus during pm_runtime suspend. If set, a complete bus 24409f6a72dSPierre-Louis Bossart * reset and re-enumeration will be performed when the bus 24509f6a72dSPierre-Louis Bossart * restarts. This mode shall not be used if Slave devices can generate 24609f6a72dSPierre-Louis Bossart * in-band wakes. 24709f6a72dSPierre-Louis Bossart */ 24809f6a72dSPierre-Louis Bossart #define SDW_INTEL_CLK_STOP_TEARDOWN BIT(1) 24909f6a72dSPierre-Louis Bossart 25009f6a72dSPierre-Louis Bossart /* 25109f6a72dSPierre-Louis Bossart * Stop the bus during pm_suspend if Slaves are not wake capable 25209f6a72dSPierre-Louis Bossart * (e.g. speaker amplifiers). The clock-stop mode is typically 25309f6a72dSPierre-Louis Bossart * slightly higher power than when the IP is completely powered-off. 25409f6a72dSPierre-Louis Bossart */ 25509f6a72dSPierre-Louis Bossart #define SDW_INTEL_CLK_STOP_WAKE_CAPABLE_ONLY BIT(2) 25609f6a72dSPierre-Louis Bossart 25709f6a72dSPierre-Louis Bossart /* 25809f6a72dSPierre-Louis Bossart * Require a bus reset (and complete re-enumeration) when exiting 25909f6a72dSPierre-Louis Bossart * clock stop modes. This may be needed if the controller power was 26009f6a72dSPierre-Louis Bossart * turned off and all context lost. This quirk shall not be used if a 26109f6a72dSPierre-Louis Bossart * Slave device needs to remain enumerated and keep its context, 26209f6a72dSPierre-Louis Bossart * e.g. to provide the reasons for the wake, report acoustic events or 26309f6a72dSPierre-Louis Bossart * pass a history buffer. 26409f6a72dSPierre-Louis Bossart */ 26509f6a72dSPierre-Louis Bossart #define SDW_INTEL_CLK_STOP_BUS_RESET BIT(3) 26609f6a72dSPierre-Louis Bossart 26792f622bcSBard Liao struct hdac_bus; 26892f622bcSBard Liao 26992f622bcSBard Liao /** 27092f622bcSBard Liao * struct sdw_intel_ctx - context allocated by the controller 27192f622bcSBard Liao * driver probe 272881cf1e9SPierre-Louis Bossart * @count: link count 273881cf1e9SPierre-Louis Bossart * @mmio_base: mmio base of SoundWire registers, only used to check 274f98f690fSPierre-Louis Bossart * hardware capabilities after all power dependencies are settled. 275f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing SoundWire links reported by the 276f98f690fSPierre-Louis Bossart * Controller 277f98f690fSPierre-Louis Bossart * @num_slaves: total number of devices exposed across all enabled links 278f98f690fSPierre-Louis Bossart * @handle: ACPI parent handle 279f98f690fSPierre-Louis Bossart * @ldev: information for each link (controller-specific and kept 280f98f690fSPierre-Louis Bossart * opaque here) 281f98f690fSPierre-Louis Bossart * @ids: array of slave_id, representing Slaves exposed across all enabled 28292f622bcSBard Liao * links 283f98f690fSPierre-Louis Bossart * @link_list: list to handle interrupts across all links 28429a269c6SPierre-Louis Bossart * @shim_lock: mutex to handle concurrent rmw access to shared SHIM registers. 285f98f690fSPierre-Louis Bossart * @shim_mask: flags to track initialization of SHIM shared registers 28692f622bcSBard Liao * @shim_base: sdw shim base. 28792f622bcSBard Liao * @alh_base: sdw alh base. 288eae0b60dSBard Liao */ 2894da0680fSPierre-Louis Bossart struct sdw_intel_ctx { 2904a17c441SPierre-Louis Bossart int count; 29160e9feb7SBard Liao void __iomem *mmio_base; 29260e9feb7SBard Liao u32 link_mask; 293f98f690fSPierre-Louis Bossart int num_slaves; 294f98f690fSPierre-Louis Bossart acpi_handle handle; 295f98f690fSPierre-Louis Bossart struct sdw_intel_link_dev **ldev; 296f98f690fSPierre-Louis Bossart struct sdw_extended_slave_id *ids; 297f98f690fSPierre-Louis Bossart struct list_head link_list; 29892f622bcSBard Liao struct mutex shim_lock; /* lock for access to shared SHIM registers */ 299f98f690fSPierre-Louis Bossart u32 shim_mask; 30029a269c6SPierre-Louis Bossart u32 shim_base; 30192f622bcSBard Liao u32 alh_base; 302eae0b60dSBard Liao }; 3034da0680fSPierre-Louis Bossart 3044a17c441SPierre-Louis Bossart /** 30560e9feb7SBard Liao * struct sdw_intel_res - Soundwire Intel global resource structure, 30660e9feb7SBard Liao * typically populated by the DSP driver 307f98f690fSPierre-Louis Bossart * 308f98f690fSPierre-Louis Bossart * @hw_ops: abstraction for platform ops 309f98f690fSPierre-Louis Bossart * @count: link count 310f98f690fSPierre-Louis Bossart * @mmio_base: mmio base of SoundWire registers 311f98f690fSPierre-Louis Bossart * @irq: interrupt number 312f98f690fSPierre-Louis Bossart * @handle: ACPI parent handle 313b3ad31f3SPierre-Louis Bossart * @parent: parent device 314f98f690fSPierre-Louis Bossart * @ops: callback ops 31571bb8a1bSVinod Koul * @dev: device implementing hwparams and free callbacks 31671bb8a1bSVinod Koul * @link_mask: bit-wise mask listing links selected by the DSP driver 31771bb8a1bSVinod Koul * This mask may be a subset of the one reported by the controller since 31871bb8a1bSVinod Koul * machine-specific quirks are handled in the DSP driver. 319c46302ecSVinod Koul * @clock_stop_quirks: mask array of possible behaviors requested by the 320f98f690fSPierre-Louis Bossart * DSP driver. The quirks are common for all links for now. 321f98f690fSPierre-Louis Bossart * @shim_base: sdw shim base. 322f98f690fSPierre-Louis Bossart * @alh_base: sdw alh base. 323f98f690fSPierre-Louis Bossart * @ext: extended HDaudio link support 32409f6a72dSPierre-Louis Bossart * @hbus: hdac_bus pointer, needed for power management 32509f6a72dSPierre-Louis Bossart * @eml_lock: mutex protecting shared registers in the HDaudio multi-link 32660e9feb7SBard Liao * space 32760e9feb7SBard Liao */ 3286ab915b9SPierre-Louis Bossart struct sdw_intel_res { 329881cf1e9SPierre-Louis Bossart const struct sdw_intel_hw_ops *hw_ops; 330ec2c9dbeSPierre-Louis Bossart int count; 331ec2c9dbeSPierre-Louis Bossart void __iomem *mmio_base; 33271bb8a1bSVinod Koul int irq; 33371bb8a1bSVinod Koul acpi_handle handle; 334b3ad31f3SPierre-Louis Bossart struct device *parent; 335f98f690fSPierre-Louis Bossart const struct sdw_intel_ops *ops; 33671bb8a1bSVinod Koul struct device *dev; 33771bb8a1bSVinod Koul u32 link_mask; 33871bb8a1bSVinod Koul u32 clock_stop_quirks; 33971bb8a1bSVinod Koul u32 shim_base; 340c46302ecSVinod Koul u32 alh_base; 341f98f690fSPierre-Louis Bossart bool ext; 342f98f690fSPierre-Louis Bossart struct hdac_bus *hbus; 34309f6a72dSPierre-Louis Bossart struct mutex *eml_lock; 34460e9feb7SBard Liao }; 34560e9feb7SBard Liao 3466ab915b9SPierre-Louis Bossart /* 347881cf1e9SPierre-Louis Bossart * On Intel platforms, the SoundWire IP has dependencies on power 348ec2c9dbeSPierre-Louis Bossart * rails shared with the DSP, and the initialization steps are split 34971bb8a1bSVinod Koul * in three. First an ACPI scan to check what the firmware describes 35071bb8a1bSVinod Koul * in DSDT tables, then an allocation step (with no hardware 351f98f690fSPierre-Louis Bossart * configuration but with all the relevant devices created) and last 352f98f690fSPierre-Louis Bossart * the actual hardware configuration. The final stage is a global 353f98f690fSPierre-Louis Bossart * interrupt enable which is controlled by the DSP driver. Splitting 354f98f690fSPierre-Louis Bossart * these phases helps simplify the boot flow and make early decisions 355f98f690fSPierre-Louis Bossart * on e.g. which machine driver to select (I2S mode, HDaudio or 356f98f690fSPierre-Louis Bossart * SoundWire). 357f98f690fSPierre-Louis Bossart */ 358f98f690fSPierre-Louis Bossart int sdw_intel_acpi_scan(acpi_handle *parent_handle, 359f98f690fSPierre-Louis Bossart struct sdw_intel_acpi_info *info); 360f98f690fSPierre-Louis Bossart 361f98f690fSPierre-Louis Bossart void sdw_intel_process_wakeen_event(struct sdw_intel_ctx *ctx); 362f98f690fSPierre-Louis Bossart 363f98f690fSPierre-Louis Bossart struct sdw_intel_ctx * 364f98f690fSPierre-Louis Bossart sdw_intel_probe(struct sdw_intel_res *res); 365f98f690fSPierre-Louis Bossart 366905b5a81SRander Wang int sdw_intel_startup(struct sdw_intel_ctx *ctx); 367905b5a81SRander Wang 368f98f690fSPierre-Louis Bossart void sdw_intel_exit(struct sdw_intel_ctx *ctx); 369f98f690fSPierre-Louis Bossart 370f98f690fSPierre-Louis Bossart irqreturn_t sdw_intel_thread(int irq, void *dev_id); 371f98f690fSPierre-Louis Bossart 372f98f690fSPierre-Louis Bossart #define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1) 373f98f690fSPierre-Louis Bossart 374f98f690fSPierre-Louis Bossart struct sdw_intel; 3756cd1d670SBard Liao 3766cd1d670SBard Liao /* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms. 37708c2a4bcSPierre-Louis Bossart * @debugfs_init: initialize all debugfs capabilities 37808c2a4bcSPierre-Louis Bossart * @debugfs_exit: close and cleanup debugfs capabilities 379b3ad31f3SPierre-Louis Bossart * @register_dai: read all PDI information and register DAIs 380b3ad31f3SPierre-Louis Bossart * @check_clock_stop: throw error message if clock is not stopped. 381b3ad31f3SPierre-Louis Bossart * @start_bus: normal start 382fb2dc6a0SPierre-Louis Bossart * @start_bus_after_reset: start after reset 383fb2dc6a0SPierre-Louis Bossart * @start_bus_after_clock_stop: start after mode0 clock stop 384b6234bccSPierre-Louis Bossart * @stop_bus: stop all bus 3853db0c5a6SPierre-Louis Bossart * @link_power_up: power-up using chip-specific helpers 3863db0c5a6SPierre-Louis Bossart * @link_power_down: power-down with chip-specific helpers 3873db0c5a6SPierre-Louis Bossart * @shim_check_wake: check if a wake was received 3883db0c5a6SPierre-Louis Bossart * @shim_wake: enable/disable in-band wake management 3893db0c5a6SPierre-Louis Bossart * @pre_bank_switch: helper for bus management 39049c9ff45SPierre-Louis Bossart * @post_bank_switch: helper for bus management 39149c9ff45SPierre-Louis Bossart * @sync_arm: helper for multi-link synchronization 39236e3b385SPierre-Louis Bossart * @sync_go_unlocked: helper for multi-link synchronization - 39336e3b385SPierre-Louis Bossart * shim_lock is assumed to be locked at higher level 394b3ad31f3SPierre-Louis Bossart * @sync_go: helper for multi-link synchronization 395b3ad31f3SPierre-Louis Bossart * @sync_check_cmdsync_unlocked: helper for multi-link synchronization 39684706e9aSPierre-Louis Bossart * and bank switch - shim_lock is assumed to be locked at higher level 39784706e9aSPierre-Louis Bossart * @program_sdi: helper for codec command/control based on dev_num 39884706e9aSPierre-Louis Bossart */ 39984706e9aSPierre-Louis Bossart struct sdw_intel_hw_ops { 4001e76de2eSPierre-Louis Bossart void (*debugfs_init)(struct sdw_intel *sdw); 4011e76de2eSPierre-Louis Bossart void (*debugfs_exit)(struct sdw_intel *sdw); 402bcf71917SPierre-Louis Bossart 403b3ad31f3SPierre-Louis Bossart int (*register_dai)(struct sdw_intel *sdw); 404b3ad31f3SPierre-Louis Bossart 405fb2dc6a0SPierre-Louis Bossart void (*check_clock_stop)(struct sdw_intel *sdw); 406fb2dc6a0SPierre-Louis Bossart int (*start_bus)(struct sdw_intel *sdw); 407fb2dc6a0SPierre-Louis Bossart int (*start_bus_after_reset)(struct sdw_intel *sdw); 408b6234bccSPierre-Louis Bossart int (*start_bus_after_clock_stop)(struct sdw_intel *sdw); 409b6234bccSPierre-Louis Bossart int (*stop_bus)(struct sdw_intel *sdw, bool clock_stop); 4103db0c5a6SPierre-Louis Bossart 4113db0c5a6SPierre-Louis Bossart int (*link_power_up)(struct sdw_intel *sdw); 4123db0c5a6SPierre-Louis Bossart int (*link_power_down)(struct sdw_intel *sdw); 4133db0c5a6SPierre-Louis Bossart 4143db0c5a6SPierre-Louis Bossart int (*shim_check_wake)(struct sdw_intel *sdw); 4153db0c5a6SPierre-Louis Bossart void (*shim_wake)(struct sdw_intel *sdw, bool wake_enable); 41649c9ff45SPierre-Louis Bossart 41749c9ff45SPierre-Louis Bossart int (*pre_bank_switch)(struct sdw_intel *sdw); 41849c9ff45SPierre-Louis Bossart int (*post_bank_switch)(struct sdw_intel *sdw); 41936e3b385SPierre-Louis Bossart 42036e3b385SPierre-Louis Bossart void (*sync_arm)(struct sdw_intel *sdw); 42136e3b385SPierre-Louis Bossart int (*sync_go_unlocked)(struct sdw_intel *sdw); 422b3ad31f3SPierre-Louis Bossart int (*sync_go)(struct sdw_intel *sdw); 423b3ad31f3SPierre-Louis Bossart bool (*sync_check_cmdsync_unlocked)(struct sdw_intel *sdw); 42484706e9aSPierre-Louis Bossart 42584706e9aSPierre-Louis Bossart void (*program_sdi)(struct sdw_intel *sdw, int dev_num); 42684706e9aSPierre-Louis Bossart }; 42784706e9aSPierre-Louis Bossart 4281e76de2eSPierre-Louis Bossart extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops; 429bcf71917SPierre-Louis Bossart extern const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops; 430bcf71917SPierre-Louis Bossart 431b3ad31f3SPierre-Louis Bossart /* 432b3ad31f3SPierre-Louis Bossart * IDA min selected to allow for 5 unconstrained devices per link, 433b3ad31f3SPierre-Louis Bossart * and 6 system-unique Device Numbers for wake-capable devices. 4346f23f4e2SPierre-Louis Bossart */ 435b3ad31f3SPierre-Louis Bossart 436*e66f91a2SPierre-Louis Bossart #define SDW_INTEL_DEV_NUM_IDA_MIN 6 437*e66f91a2SPierre-Louis Bossart 438*e66f91a2SPierre-Louis Bossart #endif 439*e66f91a2SPierre-Louis Bossart