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
11 * @assigned: pdi assigned
13 * @intel_alh_id: link identifier
14 * @l_ch_num: low channel for PDI
15 * @h_ch_num: high channel for PDI
16 * @ch_count: total channel count for PDI
17 * @dir: data direction
18 * @type: stream type, PDM or PCM
27 enum sdw_data_direction dir
;
28 enum sdw_stream_type type
;
32 * struct sdw_cdns_port: Cadence port structure
35 * @assigned: port assigned
37 * @direction: data port direction
38 * @pdi: pdi for this port
40 struct sdw_cdns_port
{
44 enum sdw_data_direction direction
;
45 struct sdw_cdns_pdi
*pdi
;
49 * struct sdw_cdns_streams: Cadence stream data structure
51 * @num_bd: number of bidirectional streams
52 * @num_in: number of input streams
53 * @num_out: number of output streams
54 * @num_ch_bd: number of bidirectional stream channels
55 * @num_ch_bd: number of input stream channels
56 * @num_ch_bd: number of output stream channels
57 * @num_pdi: total number of PDIs
58 * @bd: bidirectional streams
60 * @out: output streams
62 struct sdw_cdns_streams
{
66 unsigned int num_ch_bd
;
67 unsigned int num_ch_in
;
68 unsigned int num_ch_out
;
70 struct sdw_cdns_pdi
*bd
;
71 struct sdw_cdns_pdi
*in
;
72 struct sdw_cdns_pdi
*out
;
76 * struct sdw_cdns_stream_config: stream configuration
78 * @pcm_bd: number of bidirectional PCM streams supported
79 * @pcm_in: number of input PCM streams supported
80 * @pcm_out: number of output PCM streams supported
81 * @pdm_bd: number of bidirectional PDM streams supported
82 * @pdm_in: number of input PDM streams supported
83 * @pdm_out: number of output PDM streams supported
85 struct sdw_cdns_stream_config
{
95 * struct sdw_cdns_dma_data: Cadence DMA data
97 * @name: SoundWire stream name
98 * @nr_ports: Number of ports
101 * @stream_type: Stream type
102 * @link_id: Master link id
104 struct sdw_cdns_dma_data
{
106 struct sdw_stream_runtime
*stream
;
108 struct sdw_cdns_port
**port
;
110 enum sdw_stream_type stream_type
;
115 * struct sdw_cdns - Cadence driver context
118 * @instance: instance number
119 * @response_buf: SoundWire response buffer
120 * @tx_complete: Tx completion
121 * @defer: Defer pointer
123 * @num_ports: Total number of data ports
126 * @registers: Cadence registers
127 * @link_up: Link status
128 * @msg_count: Messages sent on bus
133 unsigned int instance
;
135 u32 response_buf
[0x80];
136 struct completion tx_complete
;
137 struct sdw_defer
*defer
;
139 struct sdw_cdns_port
*ports
;
142 struct sdw_cdns_streams pcm
;
143 struct sdw_cdns_streams pdm
;
145 void __iomem
*registers
;
148 unsigned int msg_count
;
151 #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
153 /* Exported symbols */
155 int sdw_cdns_probe(struct sdw_cdns
*cdns
);
156 extern struct sdw_master_ops sdw_cdns_master_ops
;
158 irqreturn_t
sdw_cdns_irq(int irq
, void *dev_id
);
159 irqreturn_t
sdw_cdns_thread(int irq
, void *dev_id
);
161 int sdw_cdns_init(struct sdw_cdns
*cdns
);
162 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 int sdw_cdns_get_stream(struct sdw_cdns
*cdns
,
167 struct sdw_cdns_streams
*stream
,
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
);
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
);
182 enum sdw_command_response
183 cdns_reset_page_addr(struct sdw_bus
*bus
, unsigned int dev_num
);
185 enum sdw_command_response
186 cdns_xfer_msg(struct sdw_bus
*bus
, struct sdw_msg
*msg
);
188 enum sdw_command_response
189 cdns_xfer_msg_defer(struct sdw_bus
*bus
,
190 struct sdw_msg
*msg
, struct sdw_defer
*defer
);
192 enum sdw_command_response
193 cdns_reset_page_addr(struct sdw_bus
*bus
, unsigned int dev_num
);
195 int cdns_bus_conf(struct sdw_bus
*bus
, struct sdw_bus_params
*params
);
197 int cdns_set_sdw_stream(struct snd_soc_dai
*dai
,
198 void *stream
, bool pcm
, int direction
);
199 #endif /* __SDW_CADENCE_H */