]>
Commit | Line | Data |
---|---|---|
23859465 PLB |
1 | /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ |
2 | /* Copyright(c) 2015-17 Intel Corporation. */ | |
5d6b3c8b | 3 | #include <sound/soc.h> |
2f52a517 VK |
4 | |
5 | #ifndef __SDW_CADENCE_H | |
6 | #define __SDW_CADENCE_H | |
7 | ||
07abeff1 VK |
8 | /** |
9 | * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance | |
10 | * | |
11 | * @assigned: pdi assigned | |
12 | * @num: pdi number | |
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 | |
19 | */ | |
20 | struct sdw_cdns_pdi { | |
21 | bool assigned; | |
22 | int num; | |
23 | int intel_alh_id; | |
24 | int l_ch_num; | |
25 | int h_ch_num; | |
26 | int ch_count; | |
27 | enum sdw_data_direction dir; | |
28 | enum sdw_stream_type type; | |
29 | }; | |
30 | ||
07abeff1 VK |
31 | /** |
32 | * struct sdw_cdns_streams: Cadence stream data structure | |
33 | * | |
34 | * @num_bd: number of bidirectional streams | |
35 | * @num_in: number of input streams | |
36 | * @num_out: number of output streams | |
37 | * @num_ch_bd: number of bidirectional stream channels | |
38 | * @num_ch_bd: number of input stream channels | |
39 | * @num_ch_bd: number of output stream channels | |
40 | * @num_pdi: total number of PDIs | |
41 | * @bd: bidirectional streams | |
42 | * @in: input streams | |
43 | * @out: output streams | |
44 | */ | |
45 | struct sdw_cdns_streams { | |
46 | unsigned int num_bd; | |
47 | unsigned int num_in; | |
48 | unsigned int num_out; | |
49 | unsigned int num_ch_bd; | |
50 | unsigned int num_ch_in; | |
51 | unsigned int num_ch_out; | |
52 | unsigned int num_pdi; | |
53 | struct sdw_cdns_pdi *bd; | |
54 | struct sdw_cdns_pdi *in; | |
55 | struct sdw_cdns_pdi *out; | |
56 | }; | |
57 | ||
58 | /** | |
59 | * struct sdw_cdns_stream_config: stream configuration | |
60 | * | |
61 | * @pcm_bd: number of bidirectional PCM streams supported | |
62 | * @pcm_in: number of input PCM streams supported | |
63 | * @pcm_out: number of output PCM streams supported | |
64 | * @pdm_bd: number of bidirectional PDM streams supported | |
65 | * @pdm_in: number of input PDM streams supported | |
66 | * @pdm_out: number of output PDM streams supported | |
67 | */ | |
68 | struct sdw_cdns_stream_config { | |
69 | unsigned int pcm_bd; | |
70 | unsigned int pcm_in; | |
71 | unsigned int pcm_out; | |
72 | unsigned int pdm_bd; | |
73 | unsigned int pdm_in; | |
74 | unsigned int pdm_out; | |
75 | }; | |
76 | ||
5d6b3c8b VK |
77 | /** |
78 | * struct sdw_cdns_dma_data: Cadence DMA data | |
79 | * | |
80 | * @name: SoundWire stream name | |
57a34790 PLB |
81 | * @stream: stream runtime |
82 | * @pdi: PDI used for this dai | |
5d6b3c8b VK |
83 | * @bus: Bus handle |
84 | * @stream_type: Stream type | |
85 | * @link_id: Master link id | |
86 | */ | |
87 | struct sdw_cdns_dma_data { | |
88 | char *name; | |
89 | struct sdw_stream_runtime *stream; | |
57a34790 | 90 | struct sdw_cdns_pdi *pdi; |
5d6b3c8b VK |
91 | struct sdw_bus *bus; |
92 | enum sdw_stream_type stream_type; | |
93 | int link_id; | |
94 | }; | |
95 | ||
2f52a517 VK |
96 | /** |
97 | * struct sdw_cdns - Cadence driver context | |
98 | * @dev: Linux device | |
99 | * @bus: Bus handle | |
100 | * @instance: instance number | |
956baa19 SK |
101 | * @response_buf: SoundWire response buffer |
102 | * @tx_complete: Tx completion | |
103 | * @defer: Defer pointer | |
07abeff1 VK |
104 | * @ports: Data ports |
105 | * @num_ports: Total number of data ports | |
106 | * @pcm: PCM streams | |
107 | * @pdm: PDM streams | |
2f52a517 VK |
108 | * @registers: Cadence registers |
109 | * @link_up: Link status | |
956baa19 | 110 | * @msg_count: Messages sent on bus |
2f52a517 VK |
111 | */ |
112 | struct sdw_cdns { | |
113 | struct device *dev; | |
114 | struct sdw_bus bus; | |
115 | unsigned int instance; | |
116 | ||
956baa19 SK |
117 | u32 response_buf[0x80]; |
118 | struct completion tx_complete; | |
119 | struct sdw_defer *defer; | |
120 | ||
07abeff1 VK |
121 | struct sdw_cdns_port *ports; |
122 | int num_ports; | |
123 | ||
124 | struct sdw_cdns_streams pcm; | |
125 | struct sdw_cdns_streams pdm; | |
126 | ||
2f52a517 VK |
127 | void __iomem *registers; |
128 | ||
129 | bool link_up; | |
956baa19 | 130 | unsigned int msg_count; |
2f52a517 VK |
131 | }; |
132 | ||
133 | #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus) | |
134 | ||
135 | /* Exported symbols */ | |
136 | ||
956baa19 SK |
137 | int sdw_cdns_probe(struct sdw_cdns *cdns); |
138 | extern struct sdw_master_ops sdw_cdns_master_ops; | |
139 | ||
2f52a517 VK |
140 | irqreturn_t sdw_cdns_irq(int irq, void *dev_id); |
141 | irqreturn_t sdw_cdns_thread(int irq, void *dev_id); | |
142 | ||
143 | int sdw_cdns_init(struct sdw_cdns *cdns); | |
07abeff1 | 144 | int sdw_cdns_pdi_init(struct sdw_cdns *cdns, |
806a11f0 | 145 | struct sdw_cdns_stream_config config); |
956baa19 SK |
146 | int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns); |
147 | ||
aa85066e PLB |
148 | #ifdef CONFIG_DEBUG_FS |
149 | void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root); | |
150 | #endif | |
151 | ||
5d6b3c8b VK |
152 | int sdw_cdns_get_stream(struct sdw_cdns *cdns, |
153 | struct sdw_cdns_streams *stream, | |
154 | u32 ch, u32 dir); | |
57a34790 PLB |
155 | struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns, |
156 | struct sdw_cdns_streams *stream, | |
157 | u32 ch, u32 dir); | |
158 | void sdw_cdns_config_stream(struct sdw_cdns *cdns, | |
806a11f0 | 159 | u32 ch, u32 dir, struct sdw_cdns_pdi *pdi); |
5d6b3c8b | 160 | |
5d6b3c8b | 161 | int sdw_cdns_pcm_set_stream(struct snd_soc_dai *dai, |
806a11f0 | 162 | void *stream, int direction); |
5d6b3c8b | 163 | int sdw_cdns_pdm_set_stream(struct snd_soc_dai *dai, |
806a11f0 | 164 | void *stream, int direction); |
5d6b3c8b VK |
165 | |
166 | enum sdw_command_response | |
167 | cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num); | |
168 | ||
c91605f4 SN |
169 | enum sdw_command_response |
170 | cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg); | |
2f52a517 | 171 | |
c91605f4 SN |
172 | enum sdw_command_response |
173 | cdns_xfer_msg_defer(struct sdw_bus *bus, | |
806a11f0 | 174 | struct sdw_msg *msg, struct sdw_defer *defer); |
c91605f4 SN |
175 | |
176 | enum sdw_command_response | |
177 | cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num); | |
07abeff1 VK |
178 | |
179 | int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params); | |
5d6b3c8b VK |
180 | |
181 | int cdns_set_sdw_stream(struct snd_soc_dai *dai, | |
806a11f0 | 182 | void *stream, bool pcm, int direction); |
2f52a517 | 183 | #endif /* __SDW_CADENCE_H */ |