.. | .. |
---|
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. */ |
---|
3 | 3 | #include <sound/soc.h> |
---|
4 | 4 | |
---|
5 | 5 | #ifndef __SDW_CADENCE_H |
---|
6 | 6 | #define __SDW_CADENCE_H |
---|
7 | 7 | |
---|
| 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 | + |
---|
8 | 17 | /** |
---|
9 | 18 | * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance |
---|
10 | 19 | * |
---|
11 | | - * @assigned: pdi assigned |
---|
12 | 20 | * @num: pdi number |
---|
13 | 21 | * @intel_alh_id: link identifier |
---|
14 | 22 | * @l_ch_num: low channel for PDI |
---|
.. | .. |
---|
18 | 26 | * @type: stream type, PDM or PCM |
---|
19 | 27 | */ |
---|
20 | 28 | struct sdw_cdns_pdi { |
---|
21 | | - bool assigned; |
---|
22 | 29 | int num; |
---|
23 | 30 | int intel_alh_id; |
---|
24 | 31 | int l_ch_num; |
---|
.. | .. |
---|
26 | 33 | int ch_count; |
---|
27 | 34 | enum sdw_data_direction dir; |
---|
28 | 35 | 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; |
---|
46 | 36 | }; |
---|
47 | 37 | |
---|
48 | 38 | /** |
---|
.. | .. |
---|
95 | 85 | * struct sdw_cdns_dma_data: Cadence DMA data |
---|
96 | 86 | * |
---|
97 | 87 | * @name: SoundWire stream name |
---|
98 | | - * @nr_ports: Number of ports |
---|
99 | | - * @port: Ports |
---|
| 88 | + * @stream: stream runtime |
---|
| 89 | + * @pdi: PDI used for this dai |
---|
100 | 90 | * @bus: Bus handle |
---|
101 | 91 | * @stream_type: Stream type |
---|
102 | 92 | * @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 |
---|
103 | 95 | */ |
---|
104 | 96 | struct sdw_cdns_dma_data { |
---|
105 | 97 | char *name; |
---|
106 | 98 | struct sdw_stream_runtime *stream; |
---|
107 | | - int nr_ports; |
---|
108 | | - struct sdw_cdns_port **port; |
---|
| 99 | + struct sdw_cdns_pdi *pdi; |
---|
109 | 100 | struct sdw_bus *bus; |
---|
110 | 101 | enum sdw_stream_type stream_type; |
---|
111 | 102 | int link_id; |
---|
| 103 | + struct snd_pcm_hw_params *hw_params; |
---|
| 104 | + bool suspended; |
---|
112 | 105 | }; |
---|
113 | 106 | |
---|
114 | 107 | /** |
---|
.. | .. |
---|
132 | 125 | struct sdw_bus bus; |
---|
133 | 126 | unsigned int instance; |
---|
134 | 127 | |
---|
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 | + |
---|
136 | 134 | struct completion tx_complete; |
---|
137 | 135 | struct sdw_defer *defer; |
---|
138 | 136 | |
---|
.. | .. |
---|
146 | 144 | |
---|
147 | 145 | bool link_up; |
---|
148 | 146 | unsigned int msg_count; |
---|
| 147 | + bool interrupt_enabled; |
---|
| 148 | + |
---|
| 149 | + struct work_struct work; |
---|
| 150 | + |
---|
| 151 | + struct list_head list; |
---|
149 | 152 | }; |
---|
150 | 153 | |
---|
151 | 154 | #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus) |
---|
.. | .. |
---|
160 | 163 | |
---|
161 | 164 | int sdw_cdns_init(struct sdw_cdns *cdns); |
---|
162 | 165 | 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); |
---|
165 | 169 | |
---|
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); |
---|
174 | 173 | |
---|
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); |
---|
181 | 183 | |
---|
182 | 184 | enum sdw_command_response |
---|
183 | 185 | cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num); |
---|
.. | .. |
---|
187 | 189 | |
---|
188 | 190 | enum sdw_command_response |
---|
189 | 191 | 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); |
---|
191 | 193 | |
---|
192 | 194 | enum sdw_command_response |
---|
193 | 195 | cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num); |
---|
.. | .. |
---|
195 | 197 | int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params); |
---|
196 | 198 | |
---|
197 | 199 | int cdns_set_sdw_stream(struct snd_soc_dai *dai, |
---|
198 | | - void *stream, bool pcm, int direction); |
---|
| 200 | + void *stream, bool pcm, int direction); |
---|
199 | 201 | #endif /* __SDW_CADENCE_H */ |
---|