1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /* Copyright(c) 2015-17 Intel Corporation. */
5 #ifndef __SDW_CADENCE_H
6 #define __SDW_CADENCE_H
9 * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
12 * @intel_alh_id: link identifier
13 * @l_ch_num: low channel for PDI
14 * @h_ch_num: high channel for PDI
15 * @ch_count: total channel count for PDI
16 * @dir: data direction
17 * @type: stream type, PDM or PCM
25 enum sdw_data_direction dir;
26 enum sdw_stream_type type;
30 * struct sdw_cdns_streams: Cadence stream data structure
32 * @num_bd: number of bidirectional streams
33 * @num_in: number of input streams
34 * @num_out: number of output streams
35 * @num_ch_bd: number of bidirectional stream channels
36 * @num_ch_bd: number of input stream channels
37 * @num_ch_bd: number of output stream channels
38 * @num_pdi: total number of PDIs
39 * @bd: bidirectional streams
41 * @out: output streams
43 struct sdw_cdns_streams {
47 unsigned int num_ch_bd;
48 unsigned int num_ch_in;
49 unsigned int num_ch_out;
51 struct sdw_cdns_pdi *bd;
52 struct sdw_cdns_pdi *in;
53 struct sdw_cdns_pdi *out;
57 * struct sdw_cdns_stream_config: stream configuration
59 * @pcm_bd: number of bidirectional PCM streams supported
60 * @pcm_in: number of input PCM streams supported
61 * @pcm_out: number of output PCM streams supported
62 * @pdm_bd: number of bidirectional PDM streams supported
63 * @pdm_in: number of input PDM streams supported
64 * @pdm_out: number of output PDM streams supported
66 struct sdw_cdns_stream_config {
76 * struct sdw_cdns_dma_data: Cadence DMA data
78 * @name: SoundWire stream name
79 * @stream: stream runtime
80 * @pdi: PDI used for this dai
82 * @stream_type: Stream type
83 * @link_id: Master link id
85 struct sdw_cdns_dma_data {
87 struct sdw_stream_runtime *stream;
88 struct sdw_cdns_pdi *pdi;
90 enum sdw_stream_type stream_type;
95 * struct sdw_cdns - Cadence driver context
98 * @instance: instance number
99 * @response_buf: SoundWire response buffer
100 * @tx_complete: Tx completion
101 * @defer: Defer pointer
103 * @num_ports: Total number of data ports
106 * @registers: Cadence registers
107 * @link_up: Link status
108 * @msg_count: Messages sent on bus
113 unsigned int instance;
115 u32 response_buf[0x80];
116 struct completion tx_complete;
117 struct sdw_defer *defer;
119 struct sdw_cdns_port *ports;
122 struct sdw_cdns_streams pcm;
123 struct sdw_cdns_streams pdm;
125 void __iomem *registers;
128 unsigned int msg_count;
131 #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
133 /* Exported symbols */
135 int sdw_cdns_probe(struct sdw_cdns *cdns);
136 extern struct sdw_master_ops sdw_cdns_master_ops;
138 irqreturn_t sdw_cdns_irq(int irq, void *dev_id);
139 irqreturn_t sdw_cdns_thread(int irq, void *dev_id);
141 int sdw_cdns_init(struct sdw_cdns *cdns, bool clock_stop_exit);
142 int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
143 struct sdw_cdns_stream_config config);
144 int sdw_cdns_exit_reset(struct sdw_cdns *cdns);
145 int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state);
147 #ifdef CONFIG_DEBUG_FS
148 void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root);
151 int sdw_cdns_get_stream(struct sdw_cdns *cdns,
152 struct sdw_cdns_streams *stream,
154 struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
155 struct sdw_cdns_streams *stream,
156 u32 ch, u32 dir, int dai_id);
157 void sdw_cdns_config_stream(struct sdw_cdns *cdns,
158 u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
160 int sdw_cdns_pcm_set_stream(struct snd_soc_dai *dai,
161 void *stream, int direction);
162 int sdw_cdns_pdm_set_stream(struct snd_soc_dai *dai,
163 void *stream, int direction);
165 enum sdw_command_response
166 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
168 enum sdw_command_response
169 cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
171 enum sdw_command_response
172 cdns_xfer_msg_defer(struct sdw_bus *bus,
173 struct sdw_msg *msg, struct sdw_defer *defer);
175 enum sdw_command_response
176 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
178 int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
180 int cdns_set_sdw_stream(struct snd_soc_dai *dai,
181 void *stream, bool pcm, int direction);
182 #endif /* __SDW_CADENCE_H */