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 /**
8c46302ecSVinod Koul  * struct sdw_intel_ops: Intel audio driver callback ops
9c46302ecSVinod Koul  *
10c46302ecSVinod Koul  * @config_stream: configure the stream with the hw_params
1105c8afe4SPierre-Louis Bossart  * the first argument containing the context is mandatory
12c46302ecSVinod Koul  */
13c46302ecSVinod Koul struct sdw_intel_ops {
14c46302ecSVinod Koul 	int (*config_stream)(void *arg, void *substream,
15c46302ecSVinod Koul 			     void *dai, void *hw_params, int stream_num);
16c46302ecSVinod Koul };
17c46302ecSVinod Koul 
18c46302ecSVinod Koul /**
19f98f690fSPierre-Louis Bossart  * struct sdw_intel_acpi_info - Soundwire Intel information found in ACPI tables
20f98f690fSPierre-Louis Bossart  * @handle: ACPI controller handle
21f98f690fSPierre-Louis Bossart  * @count: link count found with "sdw-master-count" property
22f98f690fSPierre-Louis Bossart  * @link_mask: bit-wise mask listing links enabled by BIOS menu
23f98f690fSPierre-Louis Bossart  *
24f98f690fSPierre-Louis Bossart  * this structure could be expanded to e.g. provide all the _ADR
25f98f690fSPierre-Louis Bossart  * information in case the link_mask is not sufficient to identify
26f98f690fSPierre-Louis Bossart  * platform capabilities.
27f98f690fSPierre-Louis Bossart  */
28f98f690fSPierre-Louis Bossart struct sdw_intel_acpi_info {
29f98f690fSPierre-Louis Bossart 	acpi_handle handle;
30f98f690fSPierre-Louis Bossart 	int count;
31f98f690fSPierre-Louis Bossart 	u32 link_mask;
32f98f690fSPierre-Louis Bossart };
33f98f690fSPierre-Louis Bossart 
34f98f690fSPierre-Louis Bossart struct sdw_intel_link_res;
35f98f690fSPierre-Louis Bossart 
36f98f690fSPierre-Louis Bossart /**
37f98f690fSPierre-Louis Bossart  * struct sdw_intel_ctx - context allocated by the controller
38f98f690fSPierre-Louis Bossart  * driver probe
39f98f690fSPierre-Louis Bossart  * @count: link count
40f98f690fSPierre-Louis Bossart  * @mmio_base: mmio base of SoundWire registers, only used to check
41f98f690fSPierre-Louis Bossart  * hardware capabilities after all power dependencies are settled.
42f98f690fSPierre-Louis Bossart  * @link_mask: bit-wise mask listing SoundWire links reported by the
43f98f690fSPierre-Louis Bossart  * Controller
44f98f690fSPierre-Louis Bossart  * @handle: ACPI parent handle
45f98f690fSPierre-Louis Bossart  * @links: information for each link (controller-specific and kept
46f98f690fSPierre-Louis Bossart  * opaque here)
47f98f690fSPierre-Louis Bossart  */
48f98f690fSPierre-Louis Bossart struct sdw_intel_ctx {
49f98f690fSPierre-Louis Bossart 	int count;
50f98f690fSPierre-Louis Bossart 	void __iomem *mmio_base;
51f98f690fSPierre-Louis Bossart 	u32 link_mask;
52f98f690fSPierre-Louis Bossart 	acpi_handle handle;
53f98f690fSPierre-Louis Bossart 	struct sdw_intel_link_res *links;
54f98f690fSPierre-Louis Bossart };
55f98f690fSPierre-Louis Bossart 
56f98f690fSPierre-Louis Bossart /**
57f98f690fSPierre-Louis Bossart  * struct sdw_intel_res - Soundwire Intel global resource structure,
58f98f690fSPierre-Louis Bossart  * typically populated by the DSP driver
59f98f690fSPierre-Louis Bossart  *
60f98f690fSPierre-Louis Bossart  * @count: link count
6171bb8a1bSVinod Koul  * @mmio_base: mmio base of SoundWire registers
6271bb8a1bSVinod Koul  * @irq: interrupt number
6371bb8a1bSVinod Koul  * @handle: ACPI parent handle
6471bb8a1bSVinod Koul  * @parent: parent device
65c46302ecSVinod Koul  * @ops: callback ops
66f98f690fSPierre-Louis Bossart  * @dev: device implementing hwparams and free callbacks
67f98f690fSPierre-Louis Bossart  * @link_mask: bit-wise mask listing links selected by the DSP driver
68f98f690fSPierre-Louis Bossart  * This mask may be a subset of the one reported by the controller since
69f98f690fSPierre-Louis Bossart  * machine-specific quirks are handled in the DSP driver.
7071bb8a1bSVinod Koul  */
7171bb8a1bSVinod Koul struct sdw_intel_res {
72f98f690fSPierre-Louis Bossart 	int count;
7371bb8a1bSVinod Koul 	void __iomem *mmio_base;
7471bb8a1bSVinod Koul 	int irq;
7571bb8a1bSVinod Koul 	acpi_handle handle;
7671bb8a1bSVinod Koul 	struct device *parent;
77c46302ecSVinod Koul 	const struct sdw_intel_ops *ops;
78f98f690fSPierre-Louis Bossart 	struct device *dev;
79f98f690fSPierre-Louis Bossart 	u32 link_mask;
8071bb8a1bSVinod Koul };
8171bb8a1bSVinod Koul 
82f98f690fSPierre-Louis Bossart /*
83f98f690fSPierre-Louis Bossart  * On Intel platforms, the SoundWire IP has dependencies on power
84f98f690fSPierre-Louis Bossart  * rails shared with the DSP, and the initialization steps are split
85f98f690fSPierre-Louis Bossart  * in three. First an ACPI scan to check what the firmware describes
86f98f690fSPierre-Louis Bossart  * in DSDT tables, then an allocation step (with no hardware
87f98f690fSPierre-Louis Bossart  * configuration but with all the relevant devices created) and last
88f98f690fSPierre-Louis Bossart  * the actual hardware configuration. The final stage is a global
89f98f690fSPierre-Louis Bossart  * interrupt enable which is controlled by the DSP driver. Splitting
90f98f690fSPierre-Louis Bossart  * these phases helps simplify the boot flow and make early decisions
91f98f690fSPierre-Louis Bossart  * on e.g. which machine driver to select (I2S mode, HDaudio or
92f98f690fSPierre-Louis Bossart  * SoundWire).
93f98f690fSPierre-Louis Bossart  */
94f98f690fSPierre-Louis Bossart int sdw_intel_acpi_scan(acpi_handle *parent_handle,
95f98f690fSPierre-Louis Bossart 			struct sdw_intel_acpi_info *info);
96f98f690fSPierre-Louis Bossart 
97f98f690fSPierre-Louis Bossart struct sdw_intel_ctx *
98f98f690fSPierre-Louis Bossart sdw_intel_probe(struct sdw_intel_res *res);
99f98f690fSPierre-Louis Bossart 
100f98f690fSPierre-Louis Bossart int sdw_intel_startup(struct sdw_intel_ctx *ctx);
101f98f690fSPierre-Louis Bossart 
102f98f690fSPierre-Louis Bossart void sdw_intel_exit(struct sdw_intel_ctx *ctx);
103f98f690fSPierre-Louis Bossart 
104f98f690fSPierre-Louis Bossart void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable);
105d62a7d41SVinod Koul 
10671bb8a1bSVinod Koul #endif
107