hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/soundwire/cadence_master.h
....@@ -1,14 +1,22 @@
1
-// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2
-// Copyright(c) 2015-17 Intel Corporation.
1
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2
+/* Copyright(c) 2015-17 Intel Corporation. */
33 #include <sound/soc.h>
44
55 #ifndef __SDW_CADENCE_H
66 #define __SDW_CADENCE_H
77
8
+#define SDW_CADENCE_GSYNC_KHZ 4 /* 4 kHz */
9
+#define SDW_CADENCE_GSYNC_HZ (SDW_CADENCE_GSYNC_KHZ * 1000)
10
+
11
+/*
12
+ * The Cadence IP supports up to 32 entries in the FIFO, though implementations
13
+ * can configure the IP to have a smaller FIFO.
14
+ */
15
+#define CDNS_MCP_IP_MAX_CMD_LEN 32
16
+
817 /**
918 * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
1019 *
11
- * @assigned: pdi assigned
1220 * @num: pdi number
1321 * @intel_alh_id: link identifier
1422 * @l_ch_num: low channel for PDI
....@@ -18,7 +26,6 @@
1826 * @type: stream type, PDM or PCM
1927 */
2028 struct sdw_cdns_pdi {
21
- bool assigned;
2229 int num;
2330 int intel_alh_id;
2431 int l_ch_num;
....@@ -26,23 +33,6 @@
2633 int ch_count;
2734 enum sdw_data_direction dir;
2835 enum sdw_stream_type type;
29
-};
30
-
31
-/**
32
- * struct sdw_cdns_port: Cadence port structure
33
- *
34
- * @num: port number
35
- * @assigned: port assigned
36
- * @ch: channel count
37
- * @direction: data port direction
38
- * @pdi: pdi for this port
39
- */
40
-struct sdw_cdns_port {
41
- unsigned int num;
42
- bool assigned;
43
- unsigned int ch;
44
- enum sdw_data_direction direction;
45
- struct sdw_cdns_pdi *pdi;
4636 };
4737
4838 /**
....@@ -95,20 +85,23 @@
9585 * struct sdw_cdns_dma_data: Cadence DMA data
9686 *
9787 * @name: SoundWire stream name
98
- * @nr_ports: Number of ports
99
- * @port: Ports
88
+ * @stream: stream runtime
89
+ * @pdi: PDI used for this dai
10090 * @bus: Bus handle
10191 * @stream_type: Stream type
10292 * @link_id: Master link id
93
+ * @hw_params: hw_params to be applied in .prepare step
94
+ * @suspended: status set when suspended, to be used in .prepare
10395 */
10496 struct sdw_cdns_dma_data {
10597 char *name;
10698 struct sdw_stream_runtime *stream;
107
- int nr_ports;
108
- struct sdw_cdns_port **port;
99
+ struct sdw_cdns_pdi *pdi;
109100 struct sdw_bus *bus;
110101 enum sdw_stream_type stream_type;
111102 int link_id;
103
+ struct snd_pcm_hw_params *hw_params;
104
+ bool suspended;
112105 };
113106
114107 /**
....@@ -132,7 +125,12 @@
132125 struct sdw_bus bus;
133126 unsigned int instance;
134127
135
- u32 response_buf[0x80];
128
+ /*
129
+ * The datasheet says the RX FIFO AVAIL can be 2 entries more
130
+ * than the FIFO capacity, so allow for this.
131
+ */
132
+ u32 response_buf[CDNS_MCP_IP_MAX_CMD_LEN + 2];
133
+
136134 struct completion tx_complete;
137135 struct sdw_defer *defer;
138136
....@@ -146,6 +144,11 @@
146144
147145 bool link_up;
148146 unsigned int msg_count;
147
+ bool interrupt_enabled;
148
+
149
+ struct work_struct work;
150
+
151
+ struct list_head list;
149152 };
150153
151154 #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
....@@ -160,24 +163,23 @@
160163
161164 int sdw_cdns_init(struct sdw_cdns *cdns);
162165 int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
163
- struct sdw_cdns_stream_config config);
164
-int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns);
166
+ struct sdw_cdns_stream_config config);
167
+int sdw_cdns_exit_reset(struct sdw_cdns *cdns);
168
+int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state);
165169
166
-int sdw_cdns_get_stream(struct sdw_cdns *cdns,
167
- struct sdw_cdns_streams *stream,
168
- u32 ch, u32 dir);
169
-int sdw_cdns_alloc_stream(struct sdw_cdns *cdns,
170
- struct sdw_cdns_streams *stream,
171
- struct sdw_cdns_port *port, u32 ch, u32 dir);
172
-void sdw_cdns_config_stream(struct sdw_cdns *cdns, struct sdw_cdns_port *port,
173
- u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
170
+bool sdw_cdns_is_clock_stop(struct sdw_cdns *cdns);
171
+int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake);
172
+int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset);
174173
175
-void sdw_cdns_shutdown(struct snd_pcm_substream *substream,
176
- struct snd_soc_dai *dai);
177
-int sdw_cdns_pcm_set_stream(struct snd_soc_dai *dai,
178
- void *stream, int direction);
179
-int sdw_cdns_pdm_set_stream(struct snd_soc_dai *dai,
180
- void *stream, int direction);
174
+#ifdef CONFIG_DEBUG_FS
175
+void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root);
176
+#endif
177
+
178
+struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
179
+ struct sdw_cdns_streams *stream,
180
+ u32 ch, u32 dir, int dai_id);
181
+void sdw_cdns_config_stream(struct sdw_cdns *cdns,
182
+ u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
181183
182184 enum sdw_command_response
183185 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
....@@ -187,7 +189,7 @@
187189
188190 enum sdw_command_response
189191 cdns_xfer_msg_defer(struct sdw_bus *bus,
190
- struct sdw_msg *msg, struct sdw_defer *defer);
192
+ struct sdw_msg *msg, struct sdw_defer *defer);
191193
192194 enum sdw_command_response
193195 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
....@@ -195,5 +197,5 @@
195197 int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
196198
197199 int cdns_set_sdw_stream(struct snd_soc_dai *dai,
198
- void *stream, bool pcm, int direction);
200
+ void *stream, bool pcm, int direction);
199201 #endif /* __SDW_CADENCE_H */