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 771bb8a1bSVinod Koul /** 84b206d34SRander Wang * struct sdw_intel_stream_params_data: configuration passed during 94b206d34SRander Wang * the @params_stream callback, e.g. for interaction with DSP 104b206d34SRander Wang * firmware. 114b206d34SRander Wang */ 124b206d34SRander Wang struct sdw_intel_stream_params_data { 134b206d34SRander Wang struct snd_pcm_substream *substream; 144b206d34SRander Wang struct snd_soc_dai *dai; 154b206d34SRander Wang struct snd_pcm_hw_params *hw_params; 164b206d34SRander Wang int link_id; 174b206d34SRander Wang int alh_stream_id; 184b206d34SRander Wang }; 194b206d34SRander Wang 204b206d34SRander Wang /** 214b206d34SRander Wang * struct sdw_intel_stream_free_data: configuration passed during 224b206d34SRander Wang * the @free_stream callback, e.g. for interaction with DSP 234b206d34SRander Wang * firmware. 244b206d34SRander Wang */ 254b206d34SRander Wang struct sdw_intel_stream_free_data { 264b206d34SRander Wang struct snd_pcm_substream *substream; 274b206d34SRander Wang struct snd_soc_dai *dai; 284b206d34SRander Wang int link_id; 294b206d34SRander Wang }; 304b206d34SRander Wang 314b206d34SRander Wang /** 32c46302ecSVinod Koul * struct sdw_intel_ops: Intel audio driver callback ops 33c46302ecSVinod Koul * 34c46302ecSVinod Koul */ 35c46302ecSVinod Koul struct sdw_intel_ops { 364b206d34SRander Wang int (*params_stream)(struct device *dev, 374b206d34SRander Wang struct sdw_intel_stream_params_data *params_data); 384b206d34SRander Wang int (*free_stream)(struct device *dev, 394b206d34SRander Wang struct sdw_intel_stream_free_data *free_data); 40c46302ecSVinod Koul }; 41c46302ecSVinod Koul 42c46302ecSVinod Koul /** 43f98f690fSPierre-Louis Bossart * struct sdw_intel_acpi_info - Soundwire Intel information found in ACPI tables 44f98f690fSPierre-Louis Bossart * @handle: ACPI controller handle 45f98f690fSPierre-Louis Bossart * @count: link count found with "sdw-master-count" property 46f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing links enabled by BIOS menu 47f98f690fSPierre-Louis Bossart * 48f98f690fSPierre-Louis Bossart * this structure could be expanded to e.g. provide all the _ADR 49f98f690fSPierre-Louis Bossart * information in case the link_mask is not sufficient to identify 50f98f690fSPierre-Louis Bossart * platform capabilities. 51f98f690fSPierre-Louis Bossart */ 52f98f690fSPierre-Louis Bossart struct sdw_intel_acpi_info { 53f98f690fSPierre-Louis Bossart acpi_handle handle; 54f98f690fSPierre-Louis Bossart int count; 55f98f690fSPierre-Louis Bossart u32 link_mask; 56f98f690fSPierre-Louis Bossart }; 57f98f690fSPierre-Louis Bossart 58f98f690fSPierre-Louis Bossart struct sdw_intel_link_res; 59f98f690fSPierre-Louis Bossart 60f98f690fSPierre-Louis Bossart /** 61f98f690fSPierre-Louis Bossart * struct sdw_intel_ctx - context allocated by the controller 62f98f690fSPierre-Louis Bossart * driver probe 63f98f690fSPierre-Louis Bossart * @count: link count 64f98f690fSPierre-Louis Bossart * @mmio_base: mmio base of SoundWire registers, only used to check 65f98f690fSPierre-Louis Bossart * hardware capabilities after all power dependencies are settled. 66f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing SoundWire links reported by the 67f98f690fSPierre-Louis Bossart * Controller 68f98f690fSPierre-Louis Bossart * @handle: ACPI parent handle 69f98f690fSPierre-Louis Bossart * @links: information for each link (controller-specific and kept 70f98f690fSPierre-Louis Bossart * opaque here) 71f98f690fSPierre-Louis Bossart */ 72f98f690fSPierre-Louis Bossart struct sdw_intel_ctx { 73f98f690fSPierre-Louis Bossart int count; 74f98f690fSPierre-Louis Bossart void __iomem *mmio_base; 75f98f690fSPierre-Louis Bossart u32 link_mask; 76f98f690fSPierre-Louis Bossart acpi_handle handle; 77f98f690fSPierre-Louis Bossart struct sdw_intel_link_res *links; 78f98f690fSPierre-Louis Bossart }; 79f98f690fSPierre-Louis Bossart 80f98f690fSPierre-Louis Bossart /** 81f98f690fSPierre-Louis Bossart * struct sdw_intel_res - Soundwire Intel global resource structure, 82f98f690fSPierre-Louis Bossart * typically populated by the DSP driver 83f98f690fSPierre-Louis Bossart * 84f98f690fSPierre-Louis Bossart * @count: link count 8571bb8a1bSVinod Koul * @mmio_base: mmio base of SoundWire registers 8671bb8a1bSVinod Koul * @irq: interrupt number 8771bb8a1bSVinod Koul * @handle: ACPI parent handle 8871bb8a1bSVinod Koul * @parent: parent device 89c46302ecSVinod Koul * @ops: callback ops 90f98f690fSPierre-Louis Bossart * @dev: device implementing hwparams and free callbacks 91f98f690fSPierre-Louis Bossart * @link_mask: bit-wise mask listing links selected by the DSP driver 92f98f690fSPierre-Louis Bossart * This mask may be a subset of the one reported by the controller since 93f98f690fSPierre-Louis Bossart * machine-specific quirks are handled in the DSP driver. 9471bb8a1bSVinod Koul */ 9571bb8a1bSVinod Koul struct sdw_intel_res { 96f98f690fSPierre-Louis Bossart int count; 9771bb8a1bSVinod Koul void __iomem *mmio_base; 9871bb8a1bSVinod Koul int irq; 9971bb8a1bSVinod Koul acpi_handle handle; 10071bb8a1bSVinod Koul struct device *parent; 101c46302ecSVinod Koul const struct sdw_intel_ops *ops; 102f98f690fSPierre-Louis Bossart struct device *dev; 103f98f690fSPierre-Louis Bossart u32 link_mask; 10471bb8a1bSVinod Koul }; 10571bb8a1bSVinod Koul 106f98f690fSPierre-Louis Bossart /* 107f98f690fSPierre-Louis Bossart * On Intel platforms, the SoundWire IP has dependencies on power 108f98f690fSPierre-Louis Bossart * rails shared with the DSP, and the initialization steps are split 109f98f690fSPierre-Louis Bossart * in three. First an ACPI scan to check what the firmware describes 110f98f690fSPierre-Louis Bossart * in DSDT tables, then an allocation step (with no hardware 111f98f690fSPierre-Louis Bossart * configuration but with all the relevant devices created) and last 112f98f690fSPierre-Louis Bossart * the actual hardware configuration. The final stage is a global 113f98f690fSPierre-Louis Bossart * interrupt enable which is controlled by the DSP driver. Splitting 114f98f690fSPierre-Louis Bossart * these phases helps simplify the boot flow and make early decisions 115f98f690fSPierre-Louis Bossart * on e.g. which machine driver to select (I2S mode, HDaudio or 116f98f690fSPierre-Louis Bossart * SoundWire). 117f98f690fSPierre-Louis Bossart */ 118f98f690fSPierre-Louis Bossart int sdw_intel_acpi_scan(acpi_handle *parent_handle, 119f98f690fSPierre-Louis Bossart struct sdw_intel_acpi_info *info); 120f98f690fSPierre-Louis Bossart 121f98f690fSPierre-Louis Bossart struct sdw_intel_ctx * 122f98f690fSPierre-Louis Bossart sdw_intel_probe(struct sdw_intel_res *res); 123f98f690fSPierre-Louis Bossart 124f98f690fSPierre-Louis Bossart int sdw_intel_startup(struct sdw_intel_ctx *ctx); 125f98f690fSPierre-Louis Bossart 126f98f690fSPierre-Louis Bossart void sdw_intel_exit(struct sdw_intel_ctx *ctx); 127f98f690fSPierre-Louis Bossart 128f98f690fSPierre-Louis Bossart void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable); 129d62a7d41SVinod Koul 13071bb8a1bSVinod Koul #endif 131