Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2/*
3 * Copyright (C) 2023-24 Advanced Micro Devices, Inc. All rights reserved.
4 */
5
6#ifndef __SDW_AMD_H
7#define __SDW_AMD_H
8
9#include <linux/acpi.h>
10#include <linux/soundwire/sdw.h>
11
12/* AMD pm_runtime quirk definitions */
13
14/*
15 * Force the clock to stop(ClockStopMode0) when suspend callback
16 * is invoked.
17 */
18#define AMD_SDW_CLK_STOP_MODE 1
19
20/*
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.
25 */
26#define AMD_SDW_POWER_OFF_MODE 2
27#define ACP_SDW0 0
28#define ACP_SDW1 1
29#define AMD_SDW_MAX_MANAGER_COUNT 2
30#define ACP63_PCI_REV_ID 0x63
31#define ACP70_PCI_REV_ID 0x70
32#define ACP71_PCI_REV_ID 0x71
33#define ACP72_PCI_REV_ID 0x72
34
35struct acp_sdw_pdata {
36 u16 instance;
37 u32 acp_rev;
38 /* mutex to protect acp common register access */
39 struct mutex *acp_sdw_lock;
40};
41
42/**
43 * struct sdw_amd_dai_runtime: AMD sdw dai runtime data
44 *
45 * @name: SoundWire stream name
46 * @stream: stream runtime
47 * @bus: Bus handle
48 * @stream_type: Stream type
49 */
50struct sdw_amd_dai_runtime {
51 char *name;
52 struct sdw_stream_runtime *stream;
53 struct sdw_bus *bus;
54 enum sdw_stream_type stream_type;
55};
56
57/**
58 * struct amd_sdw_manager - amd manager driver context
59 * @bus: bus handle
60 * @dev: linux device
61 * @mmio: SoundWire registers mmio base
62 * @acp_mmio: acp registers mmio base
63 * @amd_sdw_irq_thread: SoundWire manager irq workqueue
64 * @amd_sdw_work: peripheral status work queue
65 * @acp_sdw_lock: mutex to protect acp share register access
66 * @status: peripheral devices status array
67 * @num_din_ports: number of input ports
68 * @num_dout_ports: number of output ports
69 * @cols_index: Column index in frame shape
70 * @rows_index: Rows index in frame shape
71 * @instance: SoundWire manager instance
72 * @quirks: SoundWire manager quirks
73 * @wake_en_mask: wake enable mask per SoundWire manager
74 * @acp_rev: acp pci device revision id
75 * @clk_stopped: flag set to true when clock is stopped
76 * @power_mode_mask: flag interprets amd SoundWire manager power mode
77 * @dai_runtime_array: dai runtime array
78 */
79struct amd_sdw_manager {
80 struct sdw_bus bus;
81 struct device *dev;
82
83 void __iomem *mmio;
84 void __iomem *acp_mmio;
85
86 struct work_struct amd_sdw_irq_thread;
87 struct work_struct amd_sdw_work;
88 /* mutex to protect acp common register access */
89 struct mutex *acp_sdw_lock;
90
91 enum sdw_slave_status status[SDW_MAX_DEVICES + 1];
92
93 int num_din_ports;
94 int num_dout_ports;
95
96 int cols_index;
97 int rows_index;
98
99 u32 instance;
100 u32 quirks;
101 u32 wake_en_mask;
102 u32 power_mode_mask;
103 u32 acp_rev;
104 bool clk_stopped;
105
106 struct sdw_amd_dai_runtime **dai_runtime_array;
107};
108
109/**
110 * struct sdw_amd_acpi_info - Soundwire AMD information found in ACPI tables
111 * @handle: ACPI controller handle
112 * @count: maximum no of soundwire manager links supported on AMD platform.
113 * @link_mask: bit-wise mask listing links enabled by BIOS menu
114 */
115struct sdw_amd_acpi_info {
116 acpi_handle handle;
117 int count;
118 u32 link_mask;
119};
120
121/**
122 * struct sdw_amd_ctx - context allocated by the controller driver probe
123 *
124 * @count: link count
125 * @link_mask: bit-wise mask listing SoundWire links reported by the
126 * Controller
127 * @pdev: platform device structure
128 * @peripherals: array representing Peripherals exposed across all enabled links
129 */
130struct sdw_amd_ctx {
131 int count;
132 u32 link_mask;
133 struct platform_device *pdev[AMD_SDW_MAX_MANAGER_COUNT];
134 struct sdw_peripherals *peripherals;
135};
136
137/**
138 * struct sdw_amd_res - Soundwire AMD global resource structure,
139 * typically populated by the DSP driver/Legacy driver
140 *
141 * @acp_rev: acp pci device revision id
142 * @addr: acp pci device resource start address
143 * @reg_range: ACP register range
144 * @link_mask: bit-wise mask listing links selected by the DSP driver/
145 * legacy driver
146 * @count: link count
147 * @mmio_base: mmio base of SoundWire registers
148 * @handle: ACPI parent handle
149 * @parent: parent device
150 * @dev: device implementing hwparams and free callbacks
151 * @acp_lock: mutex protecting acp common registers access
152 */
153struct sdw_amd_res {
154 u32 acp_rev;
155 u32 addr;
156 u32 reg_range;
157 u32 link_mask;
158 int count;
159 void __iomem *mmio_base;
160 acpi_handle handle;
161 struct device *parent;
162 struct device *dev;
163 /* use to protect acp common registers access */
164 struct mutex *acp_lock;
165};
166
167int sdw_amd_probe(struct sdw_amd_res *res, struct sdw_amd_ctx **ctx);
168
169void sdw_amd_exit(struct sdw_amd_ctx *ctx);
170
171int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx);
172
173int amd_sdw_scan_controller(struct sdw_amd_acpi_info *info);
174#endif