1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
3 * Copyright (C) 2023-24 Advanced Micro Devices, Inc. All rights reserved.
9 #include <linux/acpi.h>
10 #include <linux/soundwire/sdw.h>
12 /* AMD pm_runtime quirk definitions */
15 * Force the clock to stop(ClockStopMode0) when suspend callback
18 #define AMD_SDW_CLK_STOP_MODE 1
21 * Stop the bus when runtime suspend/system level suspend callback
22 * is invoked. If set, a complete bus reset and re-enumeration will
23 * be performed when the bus restarts. In-band wake interrupts are
24 * not supported in this mode.
26 #define AMD_SDW_POWER_OFF_MODE 2
29 #define AMD_SDW_MAX_MANAGER_COUNT 2
31 struct acp_sdw_pdata {
33 /* mutex to protect acp common register access */
34 struct mutex *acp_sdw_lock;
38 * struct sdw_amd_dai_runtime: AMD sdw dai runtime data
40 * @name: SoundWire stream name
41 * @stream: stream runtime
43 * @stream_type: Stream type
45 struct sdw_amd_dai_runtime {
47 struct sdw_stream_runtime *stream;
49 enum sdw_stream_type stream_type;
53 * struct amd_sdw_manager - amd manager driver context
56 * @mmio: SoundWire registers mmio base
57 * @acp_mmio: acp registers mmio base
58 * @amd_sdw_irq_thread: SoundWire manager irq workqueue
59 * @amd_sdw_work: peripheral status work queue
60 * @acp_sdw_lock: mutex to protect acp share register access
61 * @status: peripheral devices status array
62 * @num_din_ports: number of input ports
63 * @num_dout_ports: number of output ports
64 * @cols_index: Column index in frame shape
65 * @rows_index: Rows index in frame shape
66 * @instance: SoundWire manager instance
67 * @quirks: SoundWire manager quirks
68 * @wake_en_mask: wake enable mask per SoundWire manager
69 * @clk_stopped: flag set to true when clock is stopped
70 * @power_mode_mask: flag interprets amd SoundWire manager power mode
71 * @dai_runtime_array: dai runtime array
73 struct amd_sdw_manager {
78 void __iomem *acp_mmio;
80 struct work_struct amd_sdw_irq_thread;
81 struct work_struct amd_sdw_work;
82 /* mutex to protect acp common register access */
83 struct mutex *acp_sdw_lock;
85 enum sdw_slave_status status[SDW_MAX_DEVICES + 1];
99 struct sdw_amd_dai_runtime **dai_runtime_array;
103 * struct sdw_amd_acpi_info - Soundwire AMD information found in ACPI tables
104 * @handle: ACPI controller handle
105 * @count: maximum no of soundwire manager links supported on AMD platform.
106 * @link_mask: bit-wise mask listing links enabled by BIOS menu
108 struct sdw_amd_acpi_info {
115 * struct sdw_amd_ctx - context allocated by the controller driver probe
118 * @num_slaves: total number of devices exposed across all enabled links
119 * @link_mask: bit-wise mask listing SoundWire links reported by the
121 * @ids: array of slave_id, representing Slaves exposed across all enabled
123 * @pdev: platform device structure
129 struct sdw_extended_slave_id *ids;
130 struct platform_device *pdev[AMD_SDW_MAX_MANAGER_COUNT];
134 * struct sdw_amd_res - Soundwire AMD global resource structure,
135 * typically populated by the DSP driver/Legacy driver
137 * @addr: acp pci device resource start address
138 * @reg_range: ACP register range
139 * @link_mask: bit-wise mask listing links selected by the DSP driver/
142 * @mmio_base: mmio base of SoundWire registers
143 * @handle: ACPI parent handle
144 * @parent: parent device
145 * @dev: device implementing hwparams and free callbacks
146 * @acp_lock: mutex protecting acp common registers access
153 void __iomem *mmio_base;
155 struct device *parent;
157 /* use to protect acp common registers access */
158 struct mutex *acp_lock;
161 int sdw_amd_probe(struct sdw_amd_res *res, struct sdw_amd_ctx **ctx);
163 void sdw_amd_exit(struct sdw_amd_ctx *ctx);
165 int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx);
167 int amd_sdw_scan_controller(struct sdw_amd_acpi_info *info);