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 { 185b86947b5SPierre-Louis Bossart int stream; 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 { 198b86947b5SPierre-Louis Bossart int stream; 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); 2126d1c1a73SBard Liao int (*trigger)(struct snd_soc_dai *dai, int cmd, int stream); 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 sdw_intel_slave_id { 26892f622bcSBard Liao int link_id; 26992f622bcSBard Liao struct sdw_slave_id id; 27092f622bcSBard Liao }; 27192f622bcSBard Liao 272f98f690fSPierre-Louis Bossart /** 273f98f690fSPierre-Louis Bossart * struct sdw_intel_ctx - context allocated by the controller 274f98f690fSPierre-Louis Bossart * driver probe 275f98f690fSPierre-Louis Bossart * @count: link count 276f98f690fSPierre-Louis Bossart * @mmio_base: mmio base of SoundWire registers, only used to check 277f98f690fSPierre-Louis Bossart * hardware capabilities after all power dependencies are settled. 278f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing SoundWire links reported by the 279f98f690fSPierre-Louis Bossart * Controller 28092f622bcSBard Liao * @num_slaves: total number of devices exposed across all enabled links 281f98f690fSPierre-Louis Bossart * @handle: ACPI parent handle 28229a269c6SPierre-Louis Bossart * @ldev: information for each link (controller-specific and kept 283f98f690fSPierre-Louis Bossart * opaque here) 28492f622bcSBard Liao * @ids: array of slave_id, representing Slaves exposed across all enabled 28592f622bcSBard Liao * links 286eae0b60dSBard Liao * @link_list: list to handle interrupts across all links 2874da0680fSPierre-Louis Bossart * @shim_lock: mutex to handle concurrent rmw access to shared SHIM registers. 2884a17c441SPierre-Louis Bossart * @shim_mask: flags to track initialization of SHIM shared registers 28960e9feb7SBard Liao * @shim_base: sdw shim base. 29060e9feb7SBard Liao * @alh_base: sdw alh base. 291f98f690fSPierre-Louis Bossart */ 292f98f690fSPierre-Louis Bossart struct sdw_intel_ctx { 293f98f690fSPierre-Louis Bossart int count; 294f98f690fSPierre-Louis Bossart void __iomem *mmio_base; 295f98f690fSPierre-Louis Bossart u32 link_mask; 29692f622bcSBard Liao int num_slaves; 297f98f690fSPierre-Louis Bossart acpi_handle handle; 29829a269c6SPierre-Louis Bossart struct sdw_intel_link_dev **ldev; 29992f622bcSBard Liao struct sdw_intel_slave_id *ids; 300eae0b60dSBard Liao struct list_head link_list; 3014da0680fSPierre-Louis Bossart struct mutex shim_lock; /* lock for access to shared SHIM registers */ 3024a17c441SPierre-Louis Bossart u32 shim_mask; 30360e9feb7SBard Liao u32 shim_base; 30460e9feb7SBard Liao u32 alh_base; 305f98f690fSPierre-Louis Bossart }; 306f98f690fSPierre-Louis Bossart 307f98f690fSPierre-Louis Bossart /** 308f98f690fSPierre-Louis Bossart * struct sdw_intel_res - Soundwire Intel global resource structure, 309f98f690fSPierre-Louis Bossart * typically populated by the DSP driver 310f98f690fSPierre-Louis Bossart * 311b3ad31f3SPierre-Louis Bossart * @hw_ops: abstraction for platform ops 312f98f690fSPierre-Louis Bossart * @count: link count 31371bb8a1bSVinod Koul * @mmio_base: mmio base of SoundWire registers 31471bb8a1bSVinod Koul * @irq: interrupt number 31571bb8a1bSVinod Koul * @handle: ACPI parent handle 31671bb8a1bSVinod Koul * @parent: parent device 317c46302ecSVinod Koul * @ops: callback ops 318f98f690fSPierre-Louis Bossart * @dev: device implementing hwparams and free callbacks 319f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing links selected by the DSP driver 320f98f690fSPierre-Louis Bossart * This mask may be a subset of the one reported by the controller since 321f98f690fSPierre-Louis Bossart * machine-specific quirks are handled in the DSP driver. 32209f6a72dSPierre-Louis Bossart * @clock_stop_quirks: mask array of possible behaviors requested by the 32309f6a72dSPierre-Louis Bossart * DSP driver. The quirks are common for all links for now. 32460e9feb7SBard Liao * @shim_base: sdw shim base. 32560e9feb7SBard Liao * @alh_base: sdw alh base. 326*6ab915b9SPierre-Louis Bossart * @ext: extended HDaudio link support 32771bb8a1bSVinod Koul */ 32871bb8a1bSVinod Koul struct sdw_intel_res { 329b3ad31f3SPierre-Louis Bossart const struct sdw_intel_hw_ops *hw_ops; 330f98f690fSPierre-Louis Bossart int count; 33171bb8a1bSVinod Koul void __iomem *mmio_base; 33271bb8a1bSVinod Koul int irq; 33371bb8a1bSVinod Koul acpi_handle handle; 33471bb8a1bSVinod Koul struct device *parent; 335c46302ecSVinod Koul const struct sdw_intel_ops *ops; 336f98f690fSPierre-Louis Bossart struct device *dev; 337f98f690fSPierre-Louis Bossart u32 link_mask; 33809f6a72dSPierre-Louis Bossart u32 clock_stop_quirks; 33960e9feb7SBard Liao u32 shim_base; 34060e9feb7SBard Liao u32 alh_base; 341*6ab915b9SPierre-Louis Bossart bool ext; 34271bb8a1bSVinod Koul }; 34371bb8a1bSVinod Koul 344f98f690fSPierre-Louis Bossart /* 345f98f690fSPierre-Louis Bossart * On Intel platforms, the SoundWire IP has dependencies on power 346f98f690fSPierre-Louis Bossart * rails shared with the DSP, and the initialization steps are split 347f98f690fSPierre-Louis Bossart * in three. First an ACPI scan to check what the firmware describes 348f98f690fSPierre-Louis Bossart * in DSDT tables, then an allocation step (with no hardware 349f98f690fSPierre-Louis Bossart * configuration but with all the relevant devices created) and last 350f98f690fSPierre-Louis Bossart * the actual hardware configuration. The final stage is a global 351f98f690fSPierre-Louis Bossart * interrupt enable which is controlled by the DSP driver. Splitting 352f98f690fSPierre-Louis Bossart * these phases helps simplify the boot flow and make early decisions 353f98f690fSPierre-Louis Bossart * on e.g. which machine driver to select (I2S mode, HDaudio or 354f98f690fSPierre-Louis Bossart * SoundWire). 355f98f690fSPierre-Louis Bossart */ 356f98f690fSPierre-Louis Bossart int sdw_intel_acpi_scan(acpi_handle *parent_handle, 357f98f690fSPierre-Louis Bossart struct sdw_intel_acpi_info *info); 358f98f690fSPierre-Louis Bossart 359905b5a81SRander Wang void sdw_intel_process_wakeen_event(struct sdw_intel_ctx *ctx); 360905b5a81SRander Wang 361f98f690fSPierre-Louis Bossart struct sdw_intel_ctx * 362f98f690fSPierre-Louis Bossart sdw_intel_probe(struct sdw_intel_res *res); 363f98f690fSPierre-Louis Bossart 364f98f690fSPierre-Louis Bossart int sdw_intel_startup(struct sdw_intel_ctx *ctx); 365f98f690fSPierre-Louis Bossart 366f98f690fSPierre-Louis Bossart void sdw_intel_exit(struct sdw_intel_ctx *ctx); 367f98f690fSPierre-Louis Bossart 3686cd1d670SBard Liao irqreturn_t sdw_intel_thread(int irq, void *dev_id); 3696cd1d670SBard Liao 37008c2a4bcSPierre-Louis Bossart #define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1) 37108c2a4bcSPierre-Louis Bossart 372b3ad31f3SPierre-Louis Bossart struct sdw_intel; 373b3ad31f3SPierre-Louis Bossart 374b3ad31f3SPierre-Louis Bossart /* struct intel_sdw_hw_ops - SoundWire ops for Intel platforms. 375fb2dc6a0SPierre-Louis Bossart * @debugfs_init: initialize all debugfs capabilities 376fb2dc6a0SPierre-Louis Bossart * @debugfs_exit: close and cleanup debugfs capabilities 377b6234bccSPierre-Louis Bossart * @register_dai: read all PDI information and register DAIs 3783db0c5a6SPierre-Louis Bossart * @check_clock_stop: throw error message if clock is not stopped. 3793db0c5a6SPierre-Louis Bossart * @start_bus: normal start 3803db0c5a6SPierre-Louis Bossart * @start_bus_after_reset: start after reset 3813db0c5a6SPierre-Louis Bossart * @start_bus_after_clock_stop: start after mode0 clock stop 3823db0c5a6SPierre-Louis Bossart * @stop_bus: stop all bus 38349c9ff45SPierre-Louis Bossart * @link_power_up: power-up using chip-specific helpers 38449c9ff45SPierre-Louis Bossart * @link_power_down: power-down with chip-specific helpers 38536e3b385SPierre-Louis Bossart * @shim_check_wake: check if a wake was received 38636e3b385SPierre-Louis Bossart * @shim_wake: enable/disable in-band wake management 387b3ad31f3SPierre-Louis Bossart * @pre_bank_switch: helper for bus management 388b3ad31f3SPierre-Louis Bossart * @post_bank_switch: helper for bus management 38984706e9aSPierre-Louis Bossart * @sync_arm: helper for multi-link synchronization 39084706e9aSPierre-Louis Bossart * @sync_go_unlocked: helper for multi-link synchronization - 39184706e9aSPierre-Louis Bossart * shim_lock is assumed to be locked at higher level 39284706e9aSPierre-Louis Bossart * @sync_go: helper for multi-link synchronization 3931e76de2eSPierre-Louis Bossart * @sync_check_cmdsync_unlocked: helper for multi-link synchronization 3941e76de2eSPierre-Louis Bossart * and bank switch - shim_lock is assumed to be locked at higher level 395b3ad31f3SPierre-Louis Bossart */ 396b3ad31f3SPierre-Louis Bossart struct sdw_intel_hw_ops { 397fb2dc6a0SPierre-Louis Bossart void (*debugfs_init)(struct sdw_intel *sdw); 398fb2dc6a0SPierre-Louis Bossart void (*debugfs_exit)(struct sdw_intel *sdw); 399fb2dc6a0SPierre-Louis Bossart 400b6234bccSPierre-Louis Bossart int (*register_dai)(struct sdw_intel *sdw); 401b6234bccSPierre-Louis Bossart 4023db0c5a6SPierre-Louis Bossart void (*check_clock_stop)(struct sdw_intel *sdw); 4033db0c5a6SPierre-Louis Bossart int (*start_bus)(struct sdw_intel *sdw); 4043db0c5a6SPierre-Louis Bossart int (*start_bus_after_reset)(struct sdw_intel *sdw); 4053db0c5a6SPierre-Louis Bossart int (*start_bus_after_clock_stop)(struct sdw_intel *sdw); 4063db0c5a6SPierre-Louis Bossart int (*stop_bus)(struct sdw_intel *sdw, bool clock_stop); 4073db0c5a6SPierre-Louis Bossart 40849c9ff45SPierre-Louis Bossart int (*link_power_up)(struct sdw_intel *sdw); 40949c9ff45SPierre-Louis Bossart int (*link_power_down)(struct sdw_intel *sdw); 41049c9ff45SPierre-Louis Bossart 41136e3b385SPierre-Louis Bossart int (*shim_check_wake)(struct sdw_intel *sdw); 41236e3b385SPierre-Louis Bossart void (*shim_wake)(struct sdw_intel *sdw, bool wake_enable); 41336e3b385SPierre-Louis Bossart 414b3ad31f3SPierre-Louis Bossart int (*pre_bank_switch)(struct sdw_intel *sdw); 415b3ad31f3SPierre-Louis Bossart int (*post_bank_switch)(struct sdw_intel *sdw); 41684706e9aSPierre-Louis Bossart 41784706e9aSPierre-Louis Bossart void (*sync_arm)(struct sdw_intel *sdw); 41884706e9aSPierre-Louis Bossart int (*sync_go_unlocked)(struct sdw_intel *sdw); 41984706e9aSPierre-Louis Bossart int (*sync_go)(struct sdw_intel *sdw); 4201e76de2eSPierre-Louis Bossart bool (*sync_check_cmdsync_unlocked)(struct sdw_intel *sdw); 421b3ad31f3SPierre-Louis Bossart }; 422b3ad31f3SPierre-Louis Bossart 423b3ad31f3SPierre-Louis Bossart extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops; 4246f23f4e2SPierre-Louis Bossart extern const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops; 425b3ad31f3SPierre-Louis Bossart 42671bb8a1bSVinod Koul #endif 427